self.variables = [self.W, self.U, self.b]
self._built = True
if not tfe.in_eager_mode():
self._create_variables()
self.trainable_weights = [self.W, self.U, self.b]
inputs = self._get_input_tensors(in_layers)
x, h_tm1, c_tm1 = inputs
// Taken from Keras code [citation needed]
z = model_ops.dot(x, self.W) + model_ops.dot(h_tm1, self.U) + self.b
z0 = z[:, :self.output_dim]
z1 = z[:, self.output_dim:2 * self.output_dim]
z2 = z[:, 2 * self.output_dim:3 * self.output_dim]
z3 = z[:, 3 * self.output_dim:]
i = inner_activation(z0)
f = inner_activation(z1)
c = f * c_tm1 + i * activation(z2)
o = inner_activation(z3)
h = o * activation(c)
if set_tensors:
self.h = h
self.c = c
self.out_tensor = h
return h, [h, c]
def _cosine_dist(x, y):
After Change
dtype=tf.float32)
return [W, U, b]
def create_tensor(self, in_layers=None, set_tensors=True, **kwargs):
Execute this layer on input tensors.
Parameters
----------
in_layers: list
List of three tensors (x, h_tm1, c_tm1). h_tm1 means "h, t-1".
Returns
-------
list
Returns h, [h + c]
activation = self.activation
inner_activation = self.inner_activation
if tfe.in_eager_mode():
if not self._built:
self.variables = self._create_variables()
self._built = True
W, U, b = self.variables
else:
W, U, b = self._create_variables()
inputs = self._get_input_tensors(in_layers)
x, h_tm1, c_tm1 = inputs
// Taken from Keras code [citation needed]
z = model_ops.dot(x, W) + model_ops.dot(h_tm1, U) + b
z0 = z[:, :self.output_dim]
z1 = z[:, self.output_dim:2 * self.output_dim]
z2 = z[:, 2 * self.output_dim:3 * self.output_dim]
z3 = z[:, 3 * self.output_dim:]
i = inner_activation(z0)
f = inner_activation(z1)
c = f * c_tm1 + i * activation(z2)
o = inner_activation(z3)
h = o * activation(c)
if set_tensors:
self.out_tensor = h
return h, [h, c]
def _cosine_dist(x, y):