I am implementing a Replicated Softmax Model in tensorflow. Given a batch of data, I have to sum along the rows (yielding a column vector) and I have to take an outer product of this with the hidden units bias.
Using tf.matmul(tf.squeeze(tf.reduce_sum(visible_units, 1,keepdims=True)), tf.expand_dims(self.h, 1))
causes this error InvalidArgumentError (see above for traceback): In[0] is not a matrix
Here visible_units
is a tf.placeholder
(dimension: batch_size x n_visible_units) and self.h
is hidden layer bias (n_hidden_units).
The error doesn't make sense and seems completely unrelated.
If I replace tf.matmul(tf.squeeze(tf.reduce_sum(visible_units, 1,keepdims=True)), tf.expand_dims(self.h, 1))
with just self.h
my code runs fine.
EDIT:
tf.squeeze(tf.reduce_sum(visible_units, 1,keepdims=True))
generates a 1-D tensor so just had to reshape this.