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

Function static_rnn

tensorflow/python/ops/rnn.py:1266–1444  ·  view source on GitHub ↗

Creates a recurrent neural network specified by RNNCell `cell`. The simplest form of RNN network generated is: ```python state = cell.zero_state(...) outputs = [] for input_ in inputs: output, state = cell(input_, state) outputs.append(output) return (outputs, state

(cell,
               inputs,
               initial_state=None,
               dtype=None,
               sequence_length=None,
               scope=None)

Source from the content-addressed store, hash-verified

1264 "which is equivalent to this API")
1265@tf_export(v1=["nn.static_rnn"])
1266def static_rnn(cell,
1267 inputs,
1268 initial_state=None,
1269 dtype=None,
1270 sequence_length=None,
1271 scope=None):
1272 """Creates a recurrent neural network specified by RNNCell `cell`.
1273
1274 The simplest form of RNN network generated is:
1275
1276 ```python
1277 state = cell.zero_state(...)
1278 outputs = []
1279 for input_ in inputs:
1280 output, state = cell(input_, state)
1281 outputs.append(output)
1282 return (outputs, state)
1283 ```
1284 However, a few other options are available:
1285
1286 An initial state can be provided.
1287 If the sequence_length vector is provided, dynamic calculation is performed.
1288 This method of calculation does not compute the RNN steps past the maximum
1289 sequence length of the minibatch (thus saving computational time),
1290 and properly propagates the state at an example's sequence length
1291 to the final state output.
1292
1293 The dynamic calculation performed is, at time `t` for batch row `b`,
1294
1295 ```python
1296 (output, state)(b, t) =
1297 (t >= sequence_length(b))
1298 ? (zeros(cell.output_size), states(b, sequence_length(b) - 1))
1299 : cell(input(b, t), state(b, t - 1))
1300 ```
1301
1302 Args:
1303 cell: An instance of RNNCell.
1304 inputs: A length T list of inputs, each a `Tensor` of shape `[batch_size,
1305 input_size]`, or a nested tuple of such elements.
1306 initial_state: (optional) An initial state for the RNN. If `cell.state_size`
1307 is an integer, this must be a `Tensor` of appropriate type and shape
1308 `[batch_size, cell.state_size]`. If `cell.state_size` is a tuple, this
1309 should be a tuple of tensors having shapes `[batch_size, s] for s in
1310 cell.state_size`.
1311 dtype: (optional) The data type for the initial state and expected output.
1312 Required if initial_state is not provided or RNN state has a heterogeneous
1313 dtype.
1314 sequence_length: Specifies the length of each sequence in inputs. An int32
1315 or int64 vector (tensor) size `[batch_size]`, values in `[0, T)`.
1316 scope: VariableScope for the created subgraph; defaults to "rnn".
1317
1318 Returns:
1319 A pair (outputs, state) where:
1320
1321 - outputs is a length T list of outputs (one for each input), or a nested
1322 tuple of such elements.
1323 - state is the final state

Callers 2

static_state_saving_rnnFunction · 0.70
static_bidirectional_rnnFunction · 0.70

Calls 15

_should_cacheFunction · 0.85
tupleFunction · 0.85
_is_keras_rnn_cellFunction · 0.85
variable_scopeMethod · 0.80
set_caching_deviceMethod · 0.80
with_rank_at_leastMethod · 0.80
reuse_variablesMethod · 0.80
_create_zero_outputFunction · 0.70
_rnn_stepFunction · 0.70
get_shapeMethod · 0.45
flattenMethod · 0.45
merge_withMethod · 0.45

Tested by

no test coverage detected