-
Notifications
You must be signed in to change notification settings - Fork 19.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Recurrent layer not accepting multiple inputs list despite source code seemingly handling such case #5986
Comments
This will be fixed by #5795. We're currently waiting for someone to review it. |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed after 30 days if no further activity occurs, but feel free to re-open a closed issue if needed. |
FYI, for folks reading this -- I was running into some trouble with RNNs not accepting multiple inputs. Turns out the solution was to modify the input_spec, i.e., do: |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed after 30 days if no further activity occurs, but feel free to re-open a closed issue if needed. |
This still appears to be an issue (I'm using keras 2.0.8). I have implemented my own layer that inherits from recurrent, but get a similar error when I try to pass in multiple inputs as a list. I did specify the input_spec when I initialize the layer as @jmhessel suggested, but this does not help. The issue first arises in the following lines of code from recurrent.py from call:
The assumption in these lines of code is that if the input is a list, then the input is the first element in the list, and the following items are the initial state (even if the initial_state is specified explicitly). I tried modifying this function to remove this assumption (ie. not split up the inputs in this way if the initial_state is specified), but then an error gets raised a few lines later during the call to rnn (tensorflow_backend.py, line 2332, at the beginning of the function:
which again assumes that inputs is a single tensor, and not a list of inputs, an assumption that I see is present in the rest of that function as well, including the specification of the inputs argument in the docstring. Can I conclude that the recurrent layer does not support multiple inputs in the form of a list, or am I missing something? |
Hello,
Reading the source code for Recurrent.py, it would appear that a layer like LSTM would be able to accept multiple input tensors. In call() of Recurrent, I see an option like
ifinstance(inputs, list)
then it will pick the first element of that list to be the input data tensor, and the rest as initial_states presumably.https://github.com/fchollet/keras/blob/ec9c95fdbd60c2d86288858563c57b0007b24430/keras/layers/recurrent.py#L263
However, if I run a simple script like such
I get the following exception:
I am actually trying to write a custom layer which requires two input tensors than inherits from Recurrent, but I am not sure whether I need to change the Recurrent class as well at this point... from the source code it would appear it can accept a list, and it would just use the first element of that list as the main input tensor. Can someone clarify?
The text was updated successfully, but these errors were encountered: