(feed_previous_bool)
| 110 | |
| 111 | # If feed_previous is a Tensor, we construct 2 graphs and use cond. |
| 112 | def decoder(feed_previous_bool): |
| 113 | reuse = None if feed_previous_bool else True |
| 114 | with variable_scope.variable_scope( |
| 115 | variable_scope.get_variable_scope(), reuse=reuse): |
| 116 | outputs, state = seq2seq.embedding_attention_decoder( |
| 117 | decoder_inputs, |
| 118 | encoder_state, |
| 119 | attention_states, |
| 120 | dec_cell, |
| 121 | num_decoder_symbols, |
| 122 | embedding_size, |
| 123 | num_heads=num_heads, |
| 124 | output_size=output_size, |
| 125 | output_projection=output_projection, |
| 126 | feed_previous=feed_previous_bool, |
| 127 | update_embedding_for_previous=False, |
| 128 | initial_state_attention=initial_state_attention) |
| 129 | state_list = [state] |
| 130 | if nest.is_sequence(state): |
| 131 | state_list = nest.flatten(state) |
| 132 | return outputs + state_list |
| 133 | |
| 134 | outputs_and_state = control_flow_ops.cond(feed_previous, |
| 135 | lambda: decoder(True), |
no outgoing calls
no test coverage detected