aboutsummaryrefslogtreecommitdiffhomepage
path: root/tensorflow/contrib/rnn
diff options
context:
space:
mode:
authorGravatar A. Unique TensorFlower <gardener@tensorflow.org>2018-03-12 03:13:15 -0700
committerGravatar TensorFlower Gardener <gardener@tensorflow.org>2018-03-12 03:17:39 -0700
commitcd67e8eb088537874b53b4fa52d02ff50c4a66fa (patch)
tree25d7394800ac08f3e0b19f4d9ba043e3ccc20217 /tensorflow/contrib/rnn
parent107e0904233c35791917654a82631ce2fca7bd37 (diff)
Lint some files.
PiperOrigin-RevId: 188698275
Diffstat (limited to 'tensorflow/contrib/rnn')
-rw-r--r--tensorflow/contrib/rnn/python/kernel_tests/rnn_cell_test.py14
-rw-r--r--tensorflow/contrib/rnn/python/ops/rnn_cell.py25
2 files changed, 22 insertions, 17 deletions
diff --git a/tensorflow/contrib/rnn/python/kernel_tests/rnn_cell_test.py b/tensorflow/contrib/rnn/python/kernel_tests/rnn_cell_test.py
index 69f7b8e107..f21915ffbc 100644
--- a/tensorflow/contrib/rnn/python/kernel_tests/rnn_cell_test.py
+++ b/tensorflow/contrib/rnn/python/kernel_tests/rnn_cell_test.py
@@ -878,7 +878,6 @@ class RNNCellTest(test.TestCase):
shape = [2, 1]
filter_size = [3]
num_features = 1
- batch_size = 2
expected_state_c = np.array(
[[[1.4375670191], [1.4375670191]], [[2.7542609292], [2.7542609292]]],
dtype=np.float32)
@@ -912,7 +911,6 @@ class RNNCellTest(test.TestCase):
shape = [2, 2, 1]
filter_size = [3, 3]
num_features = 1
- batch_size = 2
expected_state_c = np.array(
[[[[1.4375670191], [1.4375670191]], [[1.4375670191], [1.4375670191]]],
[[[2.7542609292], [2.7542609292]], [[2.7542609292], [2.7542609292]]
@@ -954,7 +952,6 @@ class RNNCellTest(test.TestCase):
shape = [2, 2, 2, 1]
filter_size = [3, 3, 3]
num_features = 1
- batch_size = 2
expected_state_c = np.array(
[[[[[1.4375670191], [1.4375670191]], [[1.4375670191], [1.4375670191]]
], [[[1.4375670191], [1.4375670191]], [[1.4375670191],
@@ -1584,7 +1581,7 @@ class WeightNormLSTMCellTest(test.TestCase):
"""Compared cell output with pre-calculated values."""
def _cell_output(self, cell):
- """Calculate cell output"""
+ """Calculates cell output."""
with self.test_session() as sess:
init = init_ops.constant_initializer(0.5)
@@ -1611,7 +1608,7 @@ class WeightNormLSTMCellTest(test.TestCase):
return actual_state_c, actual_state_h
def testBasicCell(self):
- """Tests cell w/o peepholes and w/o normalisation"""
+ """Tests cell w/o peepholes and w/o normalisation."""
def cell():
return contrib_rnn_cell.WeightNormLSTMCell(
@@ -1626,7 +1623,7 @@ class WeightNormLSTMCellTest(test.TestCase):
self.assertAllClose(expected_h, actual_h, 1e-5)
def testNonbasicCell(self):
- """Tests cell with peepholes and w/o normalisation"""
+ """Tests cell with peepholes and w/o normalisation."""
def cell():
return contrib_rnn_cell.WeightNormLSTMCell(
@@ -1640,9 +1637,8 @@ class WeightNormLSTMCellTest(test.TestCase):
self.assertAllClose(expected_c, actual_c, 1e-5)
self.assertAllClose(expected_h, actual_h, 1e-5)
-
def testBasicCellWithNorm(self):
- """Tests cell w/o peepholes and with normalisation"""
+ """Tests cell w/o peepholes and with normalisation."""
def cell():
return contrib_rnn_cell.WeightNormLSTMCell(
@@ -1657,7 +1653,7 @@ class WeightNormLSTMCellTest(test.TestCase):
self.assertAllClose(expected_h, actual_h, 1e-5)
def testNonBasicCellWithNorm(self):
- """Tests cell with peepholes and with normalisation"""
+ """Tests cell with peepholes and with normalisation."""
def cell():
return contrib_rnn_cell.WeightNormLSTMCell(
diff --git a/tensorflow/contrib/rnn/python/ops/rnn_cell.py b/tensorflow/contrib/rnn/python/ops/rnn_cell.py
index 3028edad1b..73f2607d84 100644
--- a/tensorflow/contrib/rnn/python/ops/rnn_cell.py
+++ b/tensorflow/contrib/rnn/python/ops/rnn_cell.py
@@ -2058,16 +2058,19 @@ class ConvLSTMCell(rnn_cell_impl.RNNCell):
initializers=None,
name="conv_lstm_cell"):
"""Construct ConvLSTMCell.
+
Args:
conv_ndims: Convolution dimensionality (1, 2 or 3).
input_shape: Shape of the input as int tuple, excluding the batch size.
output_channels: int, number of output channels of the conv LSTM.
kernel_shape: Shape of kernel as in tuple (of size 1,2 or 3).
- use_bias: Use bias in convolutions.
+ use_bias: (bool) Use bias in convolutions.
skip_connection: If set to `True`, concatenate the input to the
- output of the conv LSTM. Default: `False`.
+ output of the conv LSTM. Default: `False`.
forget_bias: Forget bias.
+ initializers: Unused.
name: Name of the module.
+
Raises:
ValueError: If `skip_connection` is `True` and stride is different from 1
or if `input_shape` is incompatible with `conv_ndims`.
@@ -2156,15 +2159,19 @@ class Conv3DLSTMCell(ConvLSTMCell):
def _conv(args, filter_size, num_features, bias, bias_start=0.0):
- """convolution:
+ """Convolution.
+
Args:
args: a Tensor or a list of Tensors of dimension 3D, 4D or 5D,
batch x n, Tensors.
filter_size: int tuple of filter height and width.
num_features: int, number of features.
+ bias: Whether to use biases in the convolution layer.
bias_start: starting value to initialize the bias; 0 by default.
+
Returns:
A 3D, 4D, or 5D Tensor with shape [batch ... num_features]
+
Raises:
ValueError: if some of the arguments has unspecified or wrong shape.
"""
@@ -2304,7 +2311,7 @@ class GLSTMCell(rnn_cell_impl.RNNCell):
return self._output_size
def _get_input_for_group(self, inputs, group_id, group_size):
- """Slices inputs into groups to prepare for processing by cell's groups
+ """Slices inputs into groups to prepare for processing by cell's groups.
Args:
inputs: cell input or it's previous state,
@@ -2705,7 +2712,7 @@ class LayerNormLSTMCell(rnn_cell_impl.RNNCell):
class SRUCell(rnn_cell_impl.LayerRNNCell):
- """SRU, Simple Recurrent Unit
+ """SRU, Simple Recurrent Unit.
Implementation based on
Training RNNs as Fast as CNNs (cf. https://arxiv.org/abs/1709.02755).
@@ -2753,12 +2760,13 @@ class SRUCell(rnn_cell_impl.LayerRNNCell):
input_depth = inputs_shape[1].value
+ # pylint: disable=protected-access
self._kernel = self.add_variable(
rnn_cell_impl._WEIGHTS_VARIABLE_NAME,
shape=[input_depth, 4 * self._num_units])
-
+ # pylint: enable=protected-access
self._bias = self.add_variable(
- rnn_cell_impl._BIAS_VARIABLE_NAME,
+ rnn_cell_impl._BIAS_VARIABLE_NAME, # pylint: disable=protected-access
shape=[2 * self._num_units],
initializer=init_ops.constant_initializer(0.0, dtype=self.dtype))
@@ -2767,7 +2775,7 @@ class SRUCell(rnn_cell_impl.LayerRNNCell):
def call(self, inputs, state):
"""Simple recurrent unit (SRU) with num_units cells."""
- U = math_ops.matmul(inputs, self._kernel)
+ U = math_ops.matmul(inputs, self._kernel) # pylint: disable=invalid-name
x_bar, f_intermediate, r_intermediate, x_tx = array_ops.split(
value=U, num_or_size_splits=4, axis=1)
@@ -2897,6 +2905,7 @@ class WeightNormLSTMCell(rnn_cell_impl.RNNCell):
Args:
args: a 2D Tensor or a list of 2D, batch x n, Tensors.
output_size: int, second dimension of W[i].
+ norm: bool, whether to normalize the weights.
bias: boolean, whether to add a bias term or not.
bias_initializer: starting value to initialize the bias
(default is all zeros).