1
私は、次のコードを実行し、この例外を取得:例外:モデルへの出力テンソルはKerasテンソルでなければなりません
base_model = VGG16(weights='imagenet')
conv4_3, conv3_3, conv2_2, conv1_2 = base_model.get_layer('block4_conv3').output, base_model.get_layer('block3_conv3').output, base_model.get_layer('block2_conv2').output, base_model.get_layer('block1_conv2').output
conv1 = Convolution2D(256, 1, 1, border_mode='same')(BatchNormalization()(conv4_3))
conv1_scaled = tf.image.resize_bilinear(conv1, (56, 56))
x = merge([BatchNormalization()(conv3_3), conv1_scaled], mode='sum')
conv2 = Convolution2D(128, 3, 3, border_mode='same', input_shape=(256, 56, 56))(x)
op = Convolution2D(2, 3, 3, border_mode='same')(conv2)
model = Model(input=base_model.input, output=op)
トレースバック:
Traceback (most recent call last):
File "keras_btp.py", line 147, in <module>
model = Model(input=base_model.input, output=op)
File "/usr/local/lib/python2.7/dist-packages/keras/engine/topology.py", line 1661, in __init__
'Keras tensors. Found: ' + str(x))
Exception: Output tensors to a Model must be Keras tensors. Found:
Tensor("add_19:0", shape=(?, 56, 56, 2), dtype=float32)
が、私はエラーがmerge
ラインであることを実感。どうすれば修正できますか?