-
Notifications
You must be signed in to change notification settings - Fork 19.7k
Description
I need to perform a different operation on each tensor slice. Therefore I need to know the batch size inside a keras layer. The call function of my layer is written below:
def call(self, inputs, mask=None):
x = inputs
input_shape = K.int_shape(inputs[0])
timesteps = input_shape[1]
x = K.reshape(x, (-1,)+ input_shape[2:])
new_input_shape = K.int_shape(x)
for i in range(new_input_shape[0]): #cant do this currently
p1 = x[i, :, :, :] #some slice operation
Currently the code does not go into the loop as new_input_shape[0] is None. Can I somehow get the batch size?
Please make sure that the boxes below are checked before you submit your issue. If your issue is an implementation question, please ask your question on StackOverflow or join the Keras Slack channel and ask there instead of filing a GitHub issue.
Thank you!
-
Check that you are up-to-date with the master branch of Keras. You can update with:
pip install git+git://github.com/fchollet/keras.git --upgrade --no-deps -
If running on TensorFlow, check that you are up-to-date with the latest version. The installation instructions can be found here.
-
If running on Theano, check that you are up-to-date with the master branch of Theano. You can update with:
pip install git+git://github.com/Theano/Theano.git --upgrade --no-deps -
Provide a link to a GitHub Gist of a Python script that can reproduce your issue (or just copy the script here if it is short).