shivank01
shivank01

Reputation: 1065

Keras: Value Error while training

I have my deep learning architecture like this:

main_input_1 = Input(shape=(50,1), dtype='float32', name='main_input_1')
main_input_2 = Input(shape=(50,1), dtype='float32', name='main_input_2')
lstm_out=LSTM(32,activation='tanh',recurrent_activation='sigmoid',return_sequences=True)
mean_pooling=AveragePooling1D(pool_size=2,strides=2,padding='valid')

lstm_out_1=lstm_out(main_input_1)
lstm_out_2=lstm_out(main_input_2)
mean_pooling_1=mean_pooling(lstm_out_1)
mean_pooling_2=mean_pooling(lstm_out_2)

concatenate_layer=Concatenate()([mean_pooling_1,mean_pooling_2])

logistic_regression_output=Dense(1,activation='softmax',name='main_output')(concatenate_layer)


model = Model(inputs=[main_input_1, main_input_2], outputs=[main_output])

I have the layers running parallel (both sides having the same structure). I am using functional api of Keras for doing the same. But while running it I got the following error:

Traceback (most recent call last):
  File "Main_Architecture.py", line 38, in <module>
    model = Model(inputs=[main_input_1, main_input_2], outputs=[main_output])
  File "/home/tpradhan/anaconda3/lib/python3.6/site-packages/keras/legacy/interfaces.py", line 91, in wrapper
    return func(*args, **kwargs)
  File "/home/tpradhan/anaconda3/lib/python3.6/site-packages/keras/engine/network.py", line 91, in __init__
    self._init_graph_network(*args, **kwargs)
  File "/home/tpradhan/anaconda3/lib/python3.6/site-packages/keras/engine/network.py", line 192, in _init_graph_network
    'Found: ' + str(x))
ValueError: Output tensors to a Model must be the output of a TensorFlow `Layer` (thus holding past layer metadata). Found: [0.00000000e+00 5.09370000e-06 8.19930500e-04 ... 9.61476653e-02
 3.62692160e-03 3.62692160e-03]

I have read the questions with similar error but none of them was useful to me. Please help me in resolving this.

Upvotes: 0

Views: 323

Answers (1)

Mitiku
Mitiku

Reputation: 5412

You are passing for outputs argument the layer name. You should pass the layer(in other words the argument value should be variable that has reference to output layer).

model = Model(inputs=[main_input_1, main_input_2], outputs=[logistic_regression_output])

Upvotes: 2

Related Questions