Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
timedistributed(dropout) error when batch_size is specified and using theano
import numpy
from keras.models import Model
from keras.layers import Input, Dropout, TimeDistributed
batch_size = 10
timesteps = 5
nb_features = 7
dropout = 0.5
input = Input(batch_shape=(batch_size, timesteps, nb_features))
a = input
a = TimeDistributed(Dropout(dropout))(a) # gives error
output = a
model = Model(input, output)
model.compile("adam", "mse")
X = numpy.random.rand(batch_size, timesteps, nb_features)
Y = model.predict_on_batch(X)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment