Intellipaat Back

Explore Courses Blog Tutorials Interview Questions
0 votes
2 views
in AI and Deep Learning by (50.2k points)

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.

Thanks a lot :)

1 Answer

0 votes
by (107k points)

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.

If you wish to know about
Keras
then visit this Artificial Intelligence Course.

31k questions

32.8k answers

501 comments

693 users

Browse Categories

...