1
$\begingroup$

I'm reading the guide on Keras website: https://keras.io/guides/sequential_model/

And it says don't use a sequential NN if you have multiple inputs or outputs.

  • What is the difference between multiple inputs and just having many input variables?
  • Does it mean having two np.arrays of features?
  • Why wouldn't someone just combine the two arrays into a single array?
  • Also, what does "multiple" outputs mean?
  • Would this just mean that you want to jointly produce two predictions?
  • Could someone give an example (non - code) of a real life application so I understand what "multiple" input and output means?

Thank you!

$\endgroup$
2
$\begingroup$
A Sequential model is not appropriate when:

- Your model has multiple inputs or multiple outputs
- Any of your layers has multiple inputs or multiple outputs
- You need to do layer sharing
- You want non-linear topology (e.g. a residual connection, a multi-branch model)

The docs suggest that you shouldn't use the Sequential API of Keras when you have such requirements as they also provide Functional API.

  • Assume that you want to caption an Image automatically. Now in the training time, you need to have images and texts both as Inputs at the same time, right? That's multiple inputs to the network.

  • Again, Assume that you want to do some image classification for some random image as well as predict the bbox coordinates of the desired object. Now you will have a regression output as well as a probability based output layer, right?

  • Another example for multiple outputs, Suppose you want to classify an image as to some class as well as find out which color has maximum coverage in the image or what's the color of the object (e.g. a black tee shirt, jeans etc). That will have multiple outputs at the very end.

  • The last variant possible is combination of both, having multiple inputs and outputs together.

Try to avoid it when your requirements are different or slightly involved...

Sample Image From link

Sample Image

| improve this answer | |
$\endgroup$
  • 1
    $\begingroup$ This: sequential is not referring to something like an LSTM or RNN, it's referring to the way that it's built: one layer on top of another. If you want to have multiple sources of input or output, you need their Functional API. $\endgroup$ – Wayne Aug 1 at 20:40
  • $\begingroup$ Precisely Wayne! $\endgroup$ – Aditya Aug 2 at 1:41

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.