I am working on a custom keras layer in tensorflow, and I need to iterate over a tensor. The problem is the tensor has shape (None, ... , ..., ...). I am not sure how to iterate over this. I tried
for i in range(len(x[:, 0, 0, 0])):
and even tf.map_fn
but both would run an infinite number of times. How do I run iterate over a tensor with one dimension being none?
CodePudding user response:
I think adding more information would be helpful. What is the tensor? Your training data? tf.map_fn should still work but maybe you need to disable eager execution first like this:
import tensorflow as tf
tf.compat.v1.disable_eager_execution()