snipsco / ntm-lasagne

Neural Turing Machines library in Theano with Lasagne
https://medium.com/snips-ai/ntm-lasagne-a-library-for-neural-turing-machines-in-lasagne-2cdce6837315#.63t84s5r5
MIT License
300 stars 51 forks source link

Variable batch size error #22

Closed terryrabinowitz closed 8 years ago

terryrabinowitz commented 8 years ago

Hello. If I set the batch size to 'None' in the input layer of the model to allow different size batches, then I get the error: "ValueError: elements of reps must be scalars of integer dtype". This error goes away when I directly connect this input layer to an output layer but appears when I try and connect the input layer to the ntm layer.

Thank you for the help and the implementation! Terry

tristandeleu commented 8 years ago

Hello Terry, Indeed, as the initializations of the memory and hidden states (for the recurrent controller) heavily rely on the size of the batches, I simply assumed they were given beforehand. Thank you for pointing that out! This should be fixed in #23 Like the other recurrent layers from Lasagne (eg. LSTMLayer), you can access the Theano variable corresponding to the size of the batches so that you can use ReshapeLayer

l_input = InputLayer((None, None, size), input_var=input_var)
batch_size, seqlen, _ = l_input.input_var.shape
terryrabinowitz commented 8 years ago

Fantastic! Thank you so much for the quick action!!

On Mon, Jun 13, 2016 at 12:08 PM, Tristan Deleu notifications@github.com wrote:

Hello Terry, Indeed, as the initializations of the memory and hidden states (for the recurrent controller) heavily rely on the size of the batches, I simply assumed they were given beforehand. Thank you for pointing that out! This should be fixed in #23 https://github.com/snipsco/ntm-lasagne/pull/23 Like the other recurrent layers from Lasagne (eg. LSTMLayer), you can access to the Theano variable corresponding to the size of the batches so that you can use ReshapeLayer

l_input = InputLayer((None, None, size), input_var=input_var) batchsize, seqlen, = l_input.input_var.shape

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/snipsco/ntm-lasagne/issues/22#issuecomment-225628393, or mute the thread https://github.com/notifications/unsubscribe/ACU0cCAyV2Ig0yrESyzJSnNRqaU-Vtnkks5qLYBkgaJpZM4I0bVn .