For loop over a tensor in TensorFlow?
I have a tensor of shape (1, M) where M is a multiple of 10. When I print the tensor it may look something like
Tensor("some_name", shape = (1, 80), dtype = float32)
This tensor is the output of a neural network which will be run in a session. I wanted to modify this tensor according to the following (broken)code:
for chunk_number in range(int(tensor.shape[1]/10)):
this_chunk = my_fn(tensor[10*chunk_number : 10*(chunk_number+1)]) // my_fn is custom
tf.assign(tensor[10*chunk_number : 10*(chunk_number+1)], this_chunk)
This is essentially like a custom activation function that selectively modifies the output.
However I cannot use a separate tf.Session() to run the tf.assign function because there will be a session running for the neural network. How do I go about this assignment?
Topic tensorflow
Category Data Science