Open matibilkis opened 3 years ago
The model you have constructed here expects an input of shape (B, 2)
. The input you are passing in your last call is (2, 100, 1)
. Maybe you meant to pass (2, 100, 2)
, which would be 2 batches, each of shape (100, 2)
. A general way of approaching this is to use tf.reshape
batched_inputs = np.random.randn(num_batches, batch_size, input_dim)
reshaped_batched_inputs = tf.reshape([-1, input_dim]) # would be of shape (num_batches * batch_size, input_dim)
flat_preds = model(batched_inputs) # would be of shape (num_batches * batch_size, 1)
preds = tf.reshape([num_batches, batch_size])
You can do the reshaping inside the model before and after the call to the layers.
cool, many thanks!
Hi,
When trying to get predictions of Lattice Models on more than one batch of data at once, Errors are raised. This is a nice feature to efficiently get predictions, and is present in basic Neural Network Keras models; find some examples in this colab.
As far as I can tell from looking at API docs + source code, this should be related to the inputs admitted by PWC layers, but I wonder if there is an easy way around.
In particular, this piece of code captures what I would like to get (and retrieves an error when calling on batched_inputs):
Thanks a lot! Matías.