【发布时间】:2017-09-11 14:42:48
【问题描述】:
是否可以使用 Keras 创建具有不同激活函数的隐藏层,它们都连接到输入层而不是相互连接?
例如一个具有 10 个神经元的隐藏层,其中 5 个神经元具有 ReLU 激活功能,5 个神经元具有 Sigmoid 激活功能。我想创建一个平板架构神经网络。
【问题讨论】:
标签: neural-network keras
是否可以使用 Keras 创建具有不同激活函数的隐藏层,它们都连接到输入层而不是相互连接?
例如一个具有 10 个神经元的隐藏层,其中 5 个神经元具有 ReLU 激活功能,5 个神经元具有 Sigmoid 激活功能。我想创建一个平板架构神经网络。
【问题讨论】:
标签: neural-network keras
您可以创建两个单独的密集层。这是最简单的方法。
分层:
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)
【讨论】: