简体   繁体   English

Pybrain的Elman Network

[英]Elman Network in Pybrain

I'm trying to make an Elman Network (aka Simple Recurent Network) with Pybrain, I think the code should look something like this: 我正在尝试使用Pybrain建立Elman网络(又称简单递归网络),我认为代码应如下所示:

n = RecurentNetwork()
n.addInputModule(LinearLayer(5, name = 'in'))
n.addModule(TanhLayer(10, name = 'hidden'))
n.addModule(LinearLayer(10, name = 'context'))
n.addOutputModule(LinearLayer(5, name = 'out'))
n.addConnection(FullConnection(n['in'], n['hidden'], name = 'in_to_hidden'))
n.addConnection(FullConnection(n['hidden'], n['out'], name = 'hidden_to_out'))
n.addConnection(IdentityConnection(n['hidden'], n['context'], name = 'hidden_to_context'))
n.addConnection(IdentityConnection(n['context'], n['hidden'], name = 'context_to_hidden')) 

My problem is that I don't know how to get the context nodes (at time t) to keep the values of the hidden nodes of the last iteration (at time t-1) in order to give them to the hidden nodes in this iteration (at time t) and how to fix the weights in hidden_to_context to be 1. How it is right now I get an error saying there is a "loop" in the net (and indeed there is one). 我的问题是,我不知道如何获取上下文节点(在时间t处)以保留上一次迭代(在时间t-1处)的隐藏节点的值,以便将它们提供给该节点。迭代(在时间t处)以及如何将hidden_​​to_context中的权重固定为1。现在怎么回事,我收到一个错误消息,说网络中存在一个“循环”(实际上确实有一个)。 Any help would be much appreciated. 任何帮助将非常感激。 Thank you very much. 非常感谢你。

Cheers, 干杯,

Bruno 布鲁诺

I would look at this section: 我会看一下这一部分:

http://pybrain.org/docs/tutorial/netmodcon.html#using-recurrent-networks http://pybrain.org/docs/tutorial/netmodcon.html#using-recurrent-networks

In particular, 尤其是,

The RecurrentNetwork class has one additional method, .addRecurrentConnection(), which looks back in time one timestep. RecurrentNetwork类还有一个其他方法,.addRecurrentConnection(),它可以在一个时间步的时间上进行回顾。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM