我正在尝试连接几个扁平化层和一个输入层:
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])
并检查输出形状等:
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())
并得到此错误:
ValueError:图形已断开:无法获得张量的值 位于“ input_3”层的Tensor(“ input_3:0”,shape =(?, 1),dtype = float32)。 可以顺利访问以下先前的图层:['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']
如何正确地将拼合层与输入层连接起来?
答案 0 :(得分:1)
问题是您没有将speed_input
包括在模型的输入中。添加它可以解决问题:
model = keras.models.Model([Dashcam_input, RADAR_INPUT, speed_input], image_and_speed)