我有一张激活功能图
activations = {'lrelu': LeakyReLU(), 'trelu': ThresholdedReLU(), 'elu': Activation('elu'), 'relu': Activation('relu'), 'selu': Activation('selu'),
'softplus': Activation('softplus'), 'tanh': Activation('tanh'), 'exponential': Activation('exponential'), 'softsign': Activation('softsign')}
first_layer = self.layers[0]
model.add(Dense(first_layer.neurons, kernel_initializer=initializer))
#model adds activation via map fine here
model.add(activations[first_layer.activation])
for x in range(1, len(self.layers)):
layer = self.layers[x]
model.add(Dense(layer.neurons))
#model does not add activation layer when i do this
model.add(activations[layer.activation])
#model does add activation layer when i do this
model.add(Activation('relu'))
model.add(Dense(1))
#compile model
#train model
print(model.summary())
基本上,我的模型为第一层增加了激活精度。但是对于下一层,它不会通过地图添加。我需要显式添加激活。出于测试目的,我有2层,并且这两层都使用relu激活。我通过地图检查并获得了激活,而在同一个对象中显式引用了激活结果,更不用说通过地图添加激活对第一层来说是正常的,但对第二层却没有?