Пример #1
0
def layer_norm(x, w, b, e=1e-5):
    sizes = x.get_output_shape()[1:]
    u = auto.mean(x, len(sizes), True)
    s = auto.mean(auto.square(x - u), len(sizes), True)
    y = (x - u) / auto.sqrt(s + e)
    y = y * w + b
    return y
Пример #2
0
 def _to_tensor(self):
     input = self.model_inputs[0].zvalue
     assert len(self.onnx_attr['axes']) == 1, "we only support axes with 1 elements for now"
     axes = self.onnx_attr['axes'][0]
     keepdims = True if self.onnx_attr['keepdims'] == 1 else False
     return autograd.mean(input, axis=int(axes), keepDims=keepdims)