# Is it possible to make a 'forked path' neural network?

I want to make a network, specifically a CNN for image recognition, that takes an input, processes it the same way for several layers, and then at some point splits before coming to two different outputs. Is it possible to create a network such as this? It would look something like this:

Input -> Conv -> Pool -> Conv -> Pool ---------> Dense -> Output 1

                                  ||

----> Dense -> Output 2


I.E. it splits off after the second pooling layer into separate fully connected layers. Of course, it has to train to both outputs, so that it is producing minimal error on both separate outputs using these common convolutional layers. Also, I am using Python Keras, and it would help if there was some way to do this using Keras in some way. Thank you!

You can find the documentation here : https://keras.io/getting-started/functional-api-guide/.

For example:

# prev_layer is the layer you want to be forked
fork1 = Dense(32, activation='relu')(prev_layer)
fork2 = Dense(32, activation='relu')(prev_layer)

# you do some operations on fork1 to get output1
# and on fork2 to get output2

model = Model(inputs=input_layer, outputs=[output1, output2])