Keras regression mu...
 
Notifications
Clear all

Keras regression multiple outputs  

  RSS

Ganesh A
(@ganesh)
Noble Member
Joined: 4 months ago
Posts: 1170
31/03/2021 11:58 am  

A question concerning Keras regression with multiple outputs:

Could you explain the difference between this net:

two inputs -> two outputs

input = Input(shape=(2,), name='bla')

hidden = Dense(hidden, activation='tanh', name='bla')(input)

output = Dense(2, activation='tanh', name='bla')(hidden)

and: two single inputs -> two single outputs:

input = Input(shape=(2,), name='speed_input')

hidden = Dense(hidden_dim, activation='tanh', name='hidden')(input)

output = Dense(1, activation='tanh', name='bla')(hidden)

input_2 = Input(shape=(1,), name='angle_input')

hidden_2 = Dense(hidden_dim, activation='tanh', name='hidden')(input_2)

output_2 = Dense(1, activation='tanh', name='bla')(hidden_2)

model = Model(inputs=[speed_input, angle_input], outputs=[speed_output, angle_output])

They behave very similarly. Other when I completely separate them, then the two nets behave like they re supposed to.

And is it normal that two single output nets behave much more intelligible than a bigger one with two outputs, I didn't think the difference could be huge like I experienced.


Quote
Anamika
(@anamika)
Noble Member
Joined: 4 months ago
Posts: 1179
31/03/2021 11:58 am  

To answer your first question both nets are still in the same Model object, but computationally they're completely separate.

In your first model, each hidden neuron receives 2 input values (as it is a 'Dense' layer, the input propagates to every neuron). In your second model, you have twice as many neurons, but each of these only receives either speed_input or angle_input, and only works with that data instead of the entire data.


ReplyQuote
Share: