I try to run this code:
outputs, states = rnn.rnn(lstm_cell, x, initial_state=initial_state, sequence_length=real_length)
tensor_shape = outputs.get_shape()
As this comment says, a workaround would be to create a NEW tensor with the previous one and a new one on the zones needed.
outputs
with 0's on the indices you want to replace and 1's elsewhere (Can work also with True
and False
)outputs
with the new desired value: new_values
outputs_new = outputs* mask + new_values * (1 - mask)
If you would provide me with an MWE I could do the code for you.
A good reference is this note: How to Replace Values by Index in a Tensor with TensorFlow-2.0