【问题标题】:Can one create disconnected hidden layers in Keras?可以在 Keras 中创建断开的隐藏层吗?
【发布时间】:2017-09-11 14:42:48
【问题描述】:

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

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

【问题讨论】:

    标签: neural-network keras


    【解决方案1】:

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

    分层:

    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)
    

    【讨论】:

      猜你喜欢
      • 2018-01-25
      • 2019-10-01
      • 2019-05-19
      • 2020-02-02
      • 2023-03-11
      • 2017-08-06
      • 2019-01-27
      • 2017-04-13
      • 1970-01-01
      相关资源
      最近更新 更多