Keras,keras.backend.concatenate和Keras.layers.Concatenate有什么区别

时间:2018-09-12 08:53:21

标签: python tensorflow keras deep-learning

我开始使用Keras。但是,我对Keras.layers.Concatenatekeras.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)

0 个答案:

没有答案