As the title says how do we compile a keras functional model with mulitple outputs?
# Multiple Outputs
from keras.utils import plot_model
from keras.models import Model
from keras.layers import Input
from keras.layers import Dense
from keras.layers.recurrent import LSTM
from keras.layers.wrappers import TimeDistributed
# input layer
visible = Input(shape=(4,2))
# feature extraction
extract = LSTM(10, return_sequences=True)(visible)
# classification output
class11 = LSTM(10)(extract)
class12 = Dense(8, activation='relu')(class11)
class13 = Dense(8, activation='relu')(class12)
output1 = Dense(9, activation='softmax')(class13)
# sequence output
output2 = TimeDistributed(Dense(1, activation='tanh'))(extract)
# output
model = Model(inputs=visible, outputs=[output1, output2])
# summarize layers
print(model.summary())
There are two output branches with two different types of output values. First output is a dense layer with softmax activation function and other output is a time distributed layer with tanh activation.
How should we compile this model. I tried this way
model.compile(optimizer=['rmsprop','adam'],
loss=['categorical_crossentropy','mse'],
metrics=['accuracy'])
But its giving this error
ValueError: ('Could not interpret optimizer identifier:', ['rmsprop', 'adam'])