MCPcopy Create free account
hub / github.com/DeepRec-AI/DeepRec / call

Method call

tensorflow/contrib/rnn/python/ops/rnn_cell.py:3379–3414  ·  view source on GitHub ↗

Independent Long short-term memory cell (IndyLSTM). Args: inputs: `2-D` tensor with shape `[batch_size, input_size]`. state: An `LSTMStateTuple` of state tensors, each shaped `[batch_size, num_units]`. Returns: A pair containing the new hidden state, and the new s

(self, inputs, state)

Source from the content-addressed store, hash-verified

3377 self.built = True
3378
3379 def call(self, inputs, state):
3380 """Independent Long short-term memory cell (IndyLSTM).
3381
3382 Args:
3383 inputs: `2-D` tensor with shape `[batch_size, input_size]`.
3384 state: An `LSTMStateTuple` of state tensors, each shaped
3385 `[batch_size, num_units]`.
3386
3387 Returns:
3388 A pair containing the new hidden state, and the new state (a
3389 `LSTMStateTuple`).
3390 """
3391 sigmoid = math_ops.sigmoid
3392 one = constant_op.constant(1, dtype=dtypes.int32)
3393 c, h = state
3394
3395 gate_inputs = math_ops.matmul(inputs, self._kernel_w)
3396 gate_inputs += gen_array_ops.tile(h, [1, 4]) * self._kernel_u
3397 gate_inputs = nn_ops.bias_add(gate_inputs, self._bias)
3398
3399 # i = input_gate, j = new_input, f = forget_gate, o = output_gate
3400 i, j, f, o = array_ops.split(
3401 value=gate_inputs, num_or_size_splits=4, axis=one)
3402
3403 forget_bias_tensor = constant_op.constant(self._forget_bias, dtype=f.dtype)
3404 # Note that using `add` and `multiply` instead of `+` and `*` gives a
3405 # performance improvement. So using those at the cost of readability.
3406 add = math_ops.add
3407 multiply = math_ops.multiply
3408 new_c = add(
3409 multiply(c, sigmoid(add(f, forget_bias_tensor))),
3410 multiply(sigmoid(i), self._activation(j)))
3411 new_h = multiply(self._activation(new_c), sigmoid(o))
3412
3413 new_state = rnn_cell_impl.LSTMStateTuple(new_c, new_h)
3414 return new_h, new_state
3415
3416
3417NTMControllerState = collections.namedtuple(

Callers

nothing calls this directly

Calls 7

tileMethod · 0.80
addFunction · 0.50
multiplyFunction · 0.50
sigmoidClass · 0.50
constantMethod · 0.45
matmulMethod · 0.45
splitMethod · 0.45

Tested by

no test coverage detected