首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >可以在Keras中创建断开连接的隐藏层吗?

可以在Keras中创建断开连接的隐藏层吗?
EN

Stack Overflow用户
提问于 2017-09-11 14:42:48
回答 1查看 375关注 0票数 0

是否可以使用Keras创建具有不同激活函数的隐藏层,它们都连接到输入层,而不是彼此连接?

例如,有10个神经元的隐层,其中5个神经元具有ReLU激活,5个神经元具有Sigmoid激活功能。我想要创建一个板结构神经网络。

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2017-09-11 15:27:05

您可以创建两个单独的致密层。这是最简单的方法。

分离层:

代码语言:javascript
运行
复制
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)
票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/46158427

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档