b688192cbd74495c9907b6dcfce47e9a582ae1af,keras/backend/tensorflow_backend.py,,rnn,#Any#Any#Any#Any#Any#,391
Before Change
// tensorflow yet for some reason it fails to in some test-cases. This
// fixes the issue, but should be removed in future.
mask.set_shape([inputs_shape[0].value, inputs_shape[1].value, 1])
mask = tf.cast(mask, tf.bool)
else:
// Transpose not supported by bool tensor types, hence round-trip to uint8.
mask = tf.cast(tf.transpose(tf.cast(mask, tf.uint8), axes), tf.bool)
After Change
if go_backwards:
input_list.reverse()
if mask is not None:
// Transpose not supported by bool tensor types, hence round-trip to uint8.
mask = tf.cast(tf.transpose(tf.cast(mask, tf.uint8), axes), tf.bool)
mask_list = tf.unpack(mask)
for input, mask_t in zip(input_list, mask_list):
output, new_states = step_function(input, states)
// tf.select needs its condition tensor to be the same shape as its two
// result tensors, but in our case the condition (mask) tensor is
// (nsamples, 1), and A and B are (nsamples, ndimensions). So we need to
// broadcast the mask to match the shape of A and B. That"s what the
// tile call does, is just repeat the mask along its second dimension
// ndimensions times.
tiled_mask_t = tf.tile(mask_t, tf.pack([1, tf.shape(output)[1]]))
if len(successive_outputs) == 0:
prev_output = zeros_like(output)
else:
prev_output = successive_outputs[-1]
output = tf.select(tiled_mask_t, output, prev_output)
return_states = []
for state, new_state in zip(states, new_states):
// (see earlier comment for tile explanation)
tiled_mask_t = tf.tile(mask_t, tf.pack([1, tf.shape(new_state)[1]]))
return_states.append(tf.select(tiled_mask_t, new_state, state))
states = return_states
successive_outputs.append(output)
successive_states.append(states)
else:
for input in input_list:
output, states = step_function(input, states)
successive_outputs.append(output)
successive_states.append(states)
last_output = successive_outputs[-1]
outputs = tf.pack(successive_outputs)
new_states = successive_states[-1]
In pattern: SUPERPATTERN
Frequency: 3
Non-data size: 6
Instances Project Name: keras-team/keras
Commit Name: b688192cbd74495c9907b6dcfce47e9a582ae1af
Time: 2016-01-31
Author: francois.chollet@gmail.com
File Name: keras/backend/tensorflow_backend.py
Class Name:
Method Name: rnn
Project Name: NifTK/NiftyNet
Commit Name: ef234844e1604d5496607fcf48886d9e556c0685
Time: 2017-06-21
Author: r.gray@ucl.ac.uk
File Name: engine/training.py
Class Name:
Method Name: run
Project Name: tensorflow/agents
Commit Name: 5886ac2bd8593b69f87181b20d2d4ddaa27dfbce
Time: 2019-01-18
Author: ebrevdo@google.com
File Name: tf_agents/networks/encoding_network.py
Class Name: EncodingNetwork
Method Name: call