简体   繁体   中英

Concatenate flatten layer with input layer

I'm trying to concatenate few flatten layers and one input layer:

navigation_flatten = Flatten()(navigator_conv)

# speed is float (0.0-1.0)
speed_input = keras.layers.Input(shape=(1,))

images_output = Concatenate()([dashcam_flatten, navigation_flatten])

image_and_speed = Concatenate()([speed_input, images_output])

And check output shapes and etc:

model = keras.models.Model([Dashcam_input, RADAR_INPUT], image_and_speed)

model.compile(loss=MSE,
              optimizer=keras.optimizers.Adam(lr=0.0001),
              metrics=['accuracy'])

print(model.summary())

And get this error:

ValueError: Graph disconnected: cannot obtain value for tensor Tensor("input_3:0", shape=(?, 1), dtype=float32) at layer "input_3". The following previous layers were accessed without issue: ['input_2', 'batch_normalization_2', 'input_1', 'conv2d_8', 'batch_normalization_1', 'max_pooling2d_4', 'conv2d_1', 'batch_normalization_3', 'conv2d_2', 'conv2d_9', 'conv2d_3', 'batch_normalization_4', 'max_pooling2d_1', 'conv2d_10', 'conv2d_4', 'batch_normalization_5', 'conv2d_5', 'conv2d_11', 'max_pooling2d_2', 'batch_normalization_6', 'conv2d_6', 'conv2d_12', 'conv2d_7', 'max_pooling2d_5', 'max_pooling2d_3', 'flatten_1', 'flatten_2']

How to right concatenate flatten layers with input layer?

The problem is that you haven't included speed_input to the inputs of your model. Adding it will solve the issue:

model = keras.models.Model([Dashcam_input, RADAR_INPUT, speed_input], image_and_speed)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM