是否可以使用Keras创建具有不同激活函数的隐藏层,它们都连接到输入层,而不是彼此连接?
例如,有10个神经元的隐层,其中5个神经元具有ReLU激活,5个神经元具有Sigmoid激活功能。我想要创建一个板结构神经网络。
发布于 2017-09-11 15:27:05
您可以创建两个单独的致密层。这是最简单的方法。
分离层:
from keras.layers import *
from keras.models import Model
#model's input and the basic syntax for creating layers
inputTensor = Input(some_shape)
outputTensor = SomeLayer(blablabla)(inputTensor)
outputTensor = AnotherLayer(bblablabla)(outputTensor)
#keep creating other layers like the previous one
#when you reach the point you want to divide:
out1 = Dense(5,activation='relu')(outputTensor)
out2 = Dense(5,activation='sigmoid')(outputTensor)
#you may concatenate the results:
outputTensor = Concatenate()([out1,out2])
#keep creating more layers....
#create the model
model = Model(inputTensor,outputTensor)https://stackoverflow.com/questions/46158427
复制相似问题