在Keras中,一层的输出与下一层的输入不匹配

2024-06-24 13:22:22 发布

您现在位置:Python中文网/ 问答频道 /正文

在我的Keras模型的一部分中,我添加了一个平均层,然后添加了一个relu激活层作为下一个层

A = Average(name='average')([Y12,Y22])
A2 = Activation('relu',name='rectified')(A)

然后我检查了A层的输出和A2层的输入

model_nr= Model(inputs=model.input,
                    outputs=[model.get_layer('average').output,
                             model.get_layer('rectified').input])

这里,蓝色的是“平均”层的输出,红色的是“校正”层的输入。 Here, the blue one is the output of 'average' and the red one is the input to layer 'rectified'.

为什么会这样?我也检查了线性激活,它会导致垃圾。 The result for using linear activation.

就好像一层的输出根本没有传递到下一层。这是Keras中的一个bug,还是我做错了什么


Tags: name模型layera2inputgetmodelactivation