def __call__(self, inputs, state, scope=None):
if self._apply_to == 'input':
with tf.variable_scope(scope or self._name):
inputs = slim.layer_norm(inputs)
return self._cell(inputs, state)
elif self._apply_to == 'output':
output, res_state = self._cell(inputs, state)
with tf.variable_scope(scope or self._name):
output = slim.layer_norm(output)
return output, res_state
elif self._apply_to == 'state':
output, res_state = self._cell(inputs, state)
with tf.variable_scope(scope or self._name):
res_state = slim.layer_norm(res_state)
return output, res_state
else:
raise ValueError('Unknown apply_to: "{}"'.format(self._apply_to))
评论列表
文章目录