I'm trying to build a graph with variable batch size, variable reshape and variable weight shape. I'm using tensorflow 1.3.0.
Using the code below, tf.get_variable throws a TypeError: int() argument must be a string or a number, not 'Tensor'. pool2 is defined somewhere else in the code.
# declare placeholder for variable batch size
images_ph = tf.placeholder(tf.float32, shape=[None, 64, 64, 1])
# code for 2 layers of convolution, normalization and max pooling
# reshape to perform, one matrix multiply
reshape = tf.reshape(pool2, [tf.shape(images_ph)[0], -1])
dim = tf.shape(reshape)[1]
var = tf.get_variable('name', [dim, 384], validate_shape=False)
I have also tried to substitute dim to have the 'correct' type as follows:
dim = reshape.get_shape()[1]
dim is equal to None and throws a ValueError: Shape of a new variable (local3/xpto) must be fully defined, but instead was (?, 384).