0

I have a tensorflow model with 2 input vectors of shapes [None, 500]. The following chunk present a similar example to what the actual model looks like (it is actually consisted of more layers but this is irrelevant to the problem which I encounter).

In addition, I have a pandas dataset of nX1000, where the first 500 inputs are the LI inputs and the second 500 are the LII inputs.

LI_input_encoder = Input(shape=(500), dtype='float32')
LI_branch_encoder = Reshape((500,1))(LI_input_encoder)
LI_branch_encoder = LSTM(250, return_sequences=True)(LI_branch_encoder)

LII_input_encoder = Input(shape=(500), dtype='float32')
LII_branch_encoder = Reshape((500,1))(LII_input_encoder)
LII_branch_encoder = LSTM(250, return_sequences=True)(LII_branch_encoder)

model_encoder = Model(inputs=[LI_input_encoder, LII_input_encoder],
                      outputs=[LI_branch_encoder, LII_branch_encoder],
                      name = "Encoder")


How to fit the model in such case? I tried two methods that did not work.

First, I tried to enter the model a list of two lists, of length 500 each. That is, I converted each row of my pd dataframe into a list of two lists, that contains the first and second 500 values. Got an error.

Then, I tried to change the model's input so it would be [None,1000] vector and then the split would occur internally, without successes unfortunately.

Thanks!

David Harar
  • 301
  • 2
  • 12
  • As far as I know, the input should be a list of two numpy arrays, with each numpy array having shape (n, 500). Something that I see in your code is that you write shape=(500), but I think that it needs to be shape=(500,), such that the value is treated as a tuple with one element instead of being treated as a single number. – Marc Felix Oct 09 '21 at 18:15
  • Hi! Have you checked these threads on multiple inputs yet? https://stackoverflow.com/questions/55233377/keras-sequential-model-with-multiple-inputs https://colab.research.google.com/github/goodboychan/chans_jupyter/blob/main/_notebooks/2020-07-28-02-Multiple-Inputs-in-keras.ipynb –  Oct 21 '21 at 13:09

0 Answers0