Skip to content

Instantly share code, notes, and snippets.

@eyaler
Created October 25, 2016 16:12
Show Gist options
  • Save eyaler/6801eee9b2134bcd518ffd34004c1475 to your computer and use it in GitHub Desktop.
Save eyaler/6801eee9b2134bcd518ffd34004c1475 to your computer and use it in GitHub Desktop.
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