如何解决图层输出的定义不明确

时间:2019-04-20 11:31:44

标签: keras resnet triplet

我想获得resnet密集层,但是输出中有些错误。我尝试使用layer [-1],它将被打印,但是layer [-4]错误。我是深度学习的新手。非常感谢。

weight_path = '/triplet_loss_resnet50.h5'
model = load_model(weight_path, compile=False)

model.summary()

# compile model
model.compile(optimizer='rmsprop',
              loss=triplet_loss,
              metrics=['accuracy'])

inp = model.input # input placeholder
outputs = model.layers[-4].output

输出消息

Layer (type)                    Output Shape         Param #     Connected to                     
==================================================================================================
input_anchor (InputLayer)       (None, 224, 224, 3)  0                                            
__________________________________________________________________________________________________
input_pos (InputLayer)          (None, 224, 224, 3)  0                                            
__________________________________________________________________________________________________
input_neg (InputLayer)          (None, 224, 224, 3)  0                                            
__________________________________________________________________________________________________
resnet_model (Model)            (None, 1000)         25636712    input_anchor[0][0]               
                                                                 input_pos[0][0]                  
                                                                 input_neg[0][0]                  
__________________________________________________________________________________________________
pos_dist (Lambda)               (None, 1)            0           resnet_model[1][0]               
                                                                 resnet_model[2][0]               
__________________________________________________________________________________________________
neg_dist (Lambda)               (None, 1)            0           resnet_model[1][0]               
                                                                 resnet_model[3][0]               
__________________________________________________________________________________________________
stacked_dists (Lambda)          (None, 2, 1)         0           pos_dist[0][0]                   
                                                                 neg_dist[0][0]                   
==================================================================================================
Total params: 25,636,712
Trainable params: 2,049,000
Non-trainable params: 23,587,712
__________________________________________________________________________________________________
Traceback (most recent call last):
AttributeError: Layer resnet_model has multiple inbound nodes, hence the notion of "layer output" is ill-defined. Use `get_output_at(node_index)` instead.

0 个答案:

没有答案