Reputation: 55
I cannot understand what is wrong. I need to have two sets of inputs so i divided them to give each one a name (serving purposes) and then concatenated them to link them to the next layer.
layer_input1 = tf.keras.Input(shape=(None, 1), name='layer1')
layer_input2 = tf.keras.Input(shape=(None, 1), name='layer2')
layer_input = tf.keras.layers.concatenate([layer_input1, layer_input2], name='inputs')
fc_1 = tf.keras.layers.Dense(2,
activation='relu')(layer_input)
fc_1 = tf.keras.layers.Dropout(0.5)(fc_1)
fc_2 = tf.keras.layers.Dense(10,
activation='relu')(fc_1)
output_layer = tf.keras.layers.Dense(1,
activation='relu', name='predictions')(fc_2)
model = tf.keras.Model(inputs=layer_input, outputs=output_layer)
AttributeError Traceback (most recent call last)
<ipython-input-430-b567199137e0> in <module>()
10 output_layer = tf.keras.layers.Dense(1,
11 activation='relu', name='predictions')(fc_2)
---> 12 model = tf.keras.Model(inputs=layer_input, outputs=output_layer)
AttributeError: 'Model' object has no attribute '_name'
Upvotes: 1
Views: 1423
Reputation: 4543
Just set your input layers as model inputs.
model = tf.keras.Model(inputs=[layer_input1, layer_input2], outputs=output_layer)
Note that concatenate is an operation, not Layer object. But even if you wrap it as Layer with Lambda it won't possess some attributes of keras.layers.Input
Upvotes: 1