I want to change the tensor using the [int, -1] notation (for example, to smooth the image). But I do not know the first dimension ahead of time. One use case is to train in a large batch, then evaluate for a smaller batch.
Why does this lead to the following error: got list containing Tensors of type '_Message' ?
import tensorflow as tf import numpy as np x = tf.placeholder(tf.float32, shape=[None, 28, 28]) batch_size = tf.placeholder(tf.int32) def reshape(_batch_size): return tf.reshape(x, [_batch_size, -1]) reshaped = reshape(batch_size) with tf.Session() as sess: sess.run([reshaped], feed_dict={x: np.random.rand(100, 28, 28), batch_size: 100})
Note: when I have a change outside the function, it seems to work, but I have very large models that I use several times, so I need to save them in the function and pass dim with an argument.
tensorflow
jstaker7
source share