Difference between Model(inputs=[input],outputs=[output1,output2]) and Model(inputs=[input],outputs=[output1]+output2) in KERAS?


Please check out the last line of the code


In the code from your link, the model outputs is defined as [decoder_outputs2] + dec_states2, where decoder_outputs2 seems to be an output from a Dense layer, and dec_states2 is a list of outputs from some other layers (dec_states = [decoder_state_h, decoder_state_c]). Therefore both [decoder_outputs2] and dec_states2 are python lists and can be concatenated using + (see How do I concatenate two lists in Python?).

Doing outputs=[decoder_outputs2] + dec_states2 means the model will have three outputs. It is equivalent to specifying outputs=[decoder_outputs2, decoder_state_h, decoder_state_c], the latter option definitely being more readable.

Answered By – druskacik

This Answer collected from stackoverflow, is licensed under cc by-sa 2.5 , cc by-sa 3.0 and cc by-sa 4.0

Leave a Reply

(*) Required, Your email will not be published