我开始使用Keras。但是,我对Keras.layers.Concatenate
和keras.backend.concatenate
之间的区别感到困惑。看起来不一样。
例如,当我使用Keras.layers.Concatenate
时,没有错误。但是,当我使用keras.backend.concatenate
时,它将报告错误:
RuntimeError: Graph disconnected: cannot obtain value for tensor Tensor("concat_1:0", shape=(?, 227, 227, 3), dtype=float32) at layer "input_2_art"
代码如下:
input_nc_tensor = Input(shape=(227, 227, 1), name='NC_input')
input_nc_tensor_3channel = keras.layers.Concatenate(axis=-1)([input_nc_tensor, input_nc_tensor, input_nc_tensor])
input_nc_tensor_3channel = keras.backend.concatenate([input_nc_tensor, input_nc_tensor, input_nc_tensor], axis=-1)
input_art_tensor = Input(shape=(227, 227, 1), name='ART_input')
input_art_tensor_3channel = keras.layers.Concatenate(axis=-1)([input_art_tensor, input_art_tensor, input_art_tensor])
input_art_tensor_3channel = keras.backend.concatenate([input_art_tensor, input_art_tensor, input_art_tensor], axis=-1)
input_pv_tensor = Input(shape=(227, 227, 1), name='PV_input')
input_pv_tensor_3channel = keras.layers.Concatenate(axis=-1)([input_pv_tensor, input_pv_tensor, input_pv_tensor])
input_pv_tensor_3channel = keras.backend.concatenate([input_pv_tensor, input_pv_tensor, input_pv_tensor], axis=-1)