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

Method call

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

Run one step of NAS Cell. Args: inputs: input Tensor, 2D, batch x num_units. state: This must be a tuple of state Tensors, both `2-D`, with column sizes `c_state` and `m_state`. Returns: A tuple containing: - A `2-D, [batch x output_dim]`, Tensor representin

(self, inputs, state)

Source from the content-addressed store, hash-verified

1543 self.built = True
1544
1545 def call(self, inputs, state):
1546 """Run one step of NAS Cell.
1547
1548 Args:
1549 inputs: input Tensor, 2D, batch x num_units.
1550 state: This must be a tuple of state Tensors, both `2-D`, with column
1551 sizes `c_state` and `m_state`.
1552
1553 Returns:
1554 A tuple containing:
1555 - A `2-D, [batch x output_dim]`, Tensor representing the output of the
1556 NAS Cell after reading `inputs` when previous state was `state`.
1557 Here output_dim is:
1558 num_proj if num_proj was set,
1559 num_units otherwise.
1560 - Tensor(s) representing the new state of NAS Cell after reading `inputs`
1561 when the previous state was `state`. Same type and shape(s) as `state`.
1562
1563 Raises:
1564 ValueError: If input size cannot be inferred from inputs via
1565 static shape inference.
1566 """
1567 sigmoid = math_ops.sigmoid
1568 tanh = math_ops.tanh
1569 relu = nn_ops.relu
1570
1571 (c_prev, m_prev) = state
1572
1573 m_matrix = math_ops.matmul(m_prev, self.recurrent_kernel)
1574 inputs_matrix = math_ops.matmul(inputs, self.kernel)
1575
1576 if self._use_bias:
1577 m_matrix = nn_ops.bias_add(m_matrix, self.bias)
1578
1579 # The NAS cell branches into 8 different splits for both the hiddenstate
1580 # and the input
1581 m_matrix_splits = array_ops.split(
1582 axis=1, num_or_size_splits=self._NAS_BASE, value=m_matrix)
1583 inputs_matrix_splits = array_ops.split(
1584 axis=1, num_or_size_splits=self._NAS_BASE, value=inputs_matrix)
1585
1586 # First layer
1587 layer1_0 = sigmoid(inputs_matrix_splits[0] + m_matrix_splits[0])
1588 layer1_1 = relu(inputs_matrix_splits[1] + m_matrix_splits[1])
1589 layer1_2 = sigmoid(inputs_matrix_splits[2] + m_matrix_splits[2])
1590 layer1_3 = relu(inputs_matrix_splits[3] * m_matrix_splits[3])
1591 layer1_4 = tanh(inputs_matrix_splits[4] + m_matrix_splits[4])
1592 layer1_5 = sigmoid(inputs_matrix_splits[5] + m_matrix_splits[5])
1593 layer1_6 = tanh(inputs_matrix_splits[6] + m_matrix_splits[6])
1594 layer1_7 = sigmoid(inputs_matrix_splits[7] + m_matrix_splits[7])
1595
1596 # Second layer
1597 l2_0 = tanh(layer1_0 * layer1_1)
1598 l2_1 = tanh(layer1_2 + layer1_3)
1599 l2_2 = tanh(layer1_4 * layer1_5)
1600 l2_3 = sigmoid(layer1_6 + layer1_7)
1601
1602 # Inject the cell

Callers

nothing calls this directly

Calls 5

sigmoidClass · 0.50
reluFunction · 0.50
tanhClass · 0.50
matmulMethod · 0.45
splitMethod · 0.45

Tested by

no test coverage detected