Reputation: 5444
Looking at Best way to flatten a 2D tensor containing a vector in TensorFlow? I see how to flatten a 2D tensor to a 1D tensor in TensorFlow but how do I flatten a 4D Tensor to a 3D Tensor with TensorFlow functions?
For example:
import tensorflow as tf
X = tf.random_normal([n, h, w, c], mean=1, stddev=4)
Y = ???
Upvotes: 2
Views: 352
Reputation: 23032
The tf.reshape()
function should work for you:
Y = tf.reshape(X, (n, h*w, c))
Upvotes: 4