So basically, my question is the same as Concatenating empty array in Numpy but for Tensorflow.
Mainly, the motivation is to handle the initial array in a prettier way that using a if statement. My current pseudo-code is:
E = None
for a in A:
if E is None:
E = a
else:
E = tf.concat([E, a], axis=0)
This technique works but I would like to make it a prettier way and maybe using only tf.Tensor
. This is a code of a custom layer so I am interested in a code that works inside a model.
I would like a solution closer to the accepted response initializing E as: E = np.array([], dtype=np.int64).reshape(0,5)
.
This question gets close enough but when I init E as:
E = tf.zeros([a.shape[0], a.shape[1], 0])
...
I get an empty tensor as a result with only the correct shape but not filled.