def _norm(self, inp, scope):
with vs.variable_scope(scope) as scope:
shape = inp.get_shape()[-1:]
gamma_init = init_ops.constant_initializer(self._g)
beta_init = init_ops.constant_initializer(self._b)
gamma = vs.get_variable("gamma", shape=shape, initializer=gamma_init) # pylint: disable=unused-variable
beta = vs.get_variable("beta", shape=shape, initializer=beta_init) # pylint: disable=unused-variable
normalized = layers.layer_norm(inp, reuse=True, scope=scope)
return normalized
评论列表
文章目录