(scope)
| 2323 | num_units = 3 |
| 2324 | |
| 2325 | def factory(scope): |
| 2326 | inputs = array_ops.placeholder( |
| 2327 | shape=(max_time, batch_size, input_depth), dtype=dtypes.float32) |
| 2328 | sequence_length = array_ops.placeholder( |
| 2329 | shape=(batch_size,), dtype=dtypes.int32) |
| 2330 | inputs_ta = tensor_array_ops.TensorArray( |
| 2331 | dtype=dtypes.float32, size=array_ops.shape(inputs)[0]) |
| 2332 | inputs_ta = inputs_ta.unstack(inputs) |
| 2333 | |
| 2334 | cell = rnn_cell.LSTMCell(num_units, state_is_tuple=True) |
| 2335 | |
| 2336 | def loop_fn(time_, cell_output, cell_state, unused_loop_state): |
| 2337 | emit_output = cell_output # == None for time == 0 |
| 2338 | if cell_output is None: # time == 0 |
| 2339 | next_state = cell.zero_state(batch_size, dtypes.float32) |
| 2340 | else: |
| 2341 | next_state = cell_state |
| 2342 | |
| 2343 | elements_finished = (time_ >= sequence_length) |
| 2344 | finished = math_ops.reduce_all(elements_finished) |
| 2345 | # For the very final iteration, we must emit a dummy input |
| 2346 | next_input = control_flow_ops.cond( |
| 2347 | finished, |
| 2348 | lambda: array_ops.zeros([batch_size, input_depth], dtype=dtypes.float32), |
| 2349 | lambda: inputs_ta.read(time_)) |
| 2350 | return (elements_finished, next_input, next_state, emit_output, None) |
| 2351 | |
| 2352 | return rnn.raw_rnn(cell, loop_fn, scope=scope) |
| 2353 | |
| 2354 | self._testScope(factory, use_outer_scope=True) |
| 2355 | self._testScope(factory, use_outer_scope=False) |
nothing calls this directly
no test coverage detected