I am trying to make a CNN model that takes variable size input (sentence matrix) and produce a fixed size output for a subsequent fully connected layer (similar to this paper).
I am trying to implement a dynamic kernel size for a max pooling layer so I need the shape of the input at runtime to achieve this.
input = tf.placeholder(tf.float32)
# convolution layer here ....
tf.nn.max_pool(convolution_output, ksize=[1, s, 1, 1],
strides=[1, 1, 1, 1], padding='VALID')
s in ksize=[1, s, 1, 1] should be inferred from the input shape.
However, I can't find a way to do it with Tensorflow.
Anyone knows a way to do it?
tf.reduce_maxcould work in this case? Not sure if this will for the paper you are implementing, but at least it works for simple CNN with variable input size.