【问题标题】:how to set custom hiddenclass function in pybrain?如何在 pybrain 中设置自定义 hiddenclass 函数?
【发布时间】:2014-04-10 15:28:17
【问题描述】:

我想训练一个具有 (1,Nh,1,1) 的神经网络(一个输入,第一个隐藏层中的 Nh 个神经元,第二个隐藏层中的 1 个神经元和 1 个输出)。

在第二个隐藏层中,我想使用自定义函数。

有什么简单的方法可以做到吗? 我正在使用pybrain。

谢谢!

【问题讨论】:

    标签: machine-learning neural-network pybrain


    【解决方案1】:

    您需要使用自定义的 Forward 和 Backward 逻辑来实现您自己的从 NeuronLayer 派生的层。比如:

    from pybrain.structure.modules.neuronlayer import NeuronLayer
    
    class CustomLayer(NeuronLayer):
    """Layer implementing the custom function."""
    
    def _forwardImplementation(self, inbuf, outbuf):
        outbuf[:] = custom_func_fwd(inbuf)
    
    def _backwardImplementation(self, outerr, inerr, outbuf, inbuf):
        inerr[:] = custom_func_bkwd(outbuf,outerr)
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2018-04-27
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-06-28
      • 1970-01-01
      • 2022-09-24
      • 1970-01-01
      相关资源
      最近更新 更多