本文整理汇总了Python中pybrain.structure.FeedForwardNetwork.addRecurrentConnection方法的典型用法代码示例。如果您正苦于以下问题:Python FeedForwardNetwork.addRecurrentConnection方法的具体用法?Python FeedForwardNetwork.addRecurrentConnection怎么用?Python FeedForwardNetwork.addRecurrentConnection使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pybrain.structure.FeedForwardNetwork
的用法示例。
在下文中一共展示了FeedForwardNetwork.addRecurrentConnection方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: LinearLayer
# 需要导入模块: from pybrain.structure import FeedForwardNetwork [as 别名]
# 或者: from pybrain.structure.FeedForwardNetwork import addRecurrentConnection [as 别名]
print in_to_hidden.params
print hidden_to_out.params
print n.params
print n.activate([1, 2])
# Naming your NN
print LinearLayer(2).name
LinearLayer(2, name='foo')
print LinearLayer(2).name
# Using Recurrent NN
n = RecurrentNetwork()
n.addInputModule(LinearLayer(2, name='in'))
n.addModule(SigmoidLayer(3, name='hidden'))
n.addOutputModule(LinearLayer(1, name='out'))
n.addConnection(FullConnection(n['in'], n['hidden'], name='c1'))
n.addConnection(FullConnection(n['hidden'], n['out'], name='c2'))
# Looks back in time one timestep
n.addRecurrentConnection(FullConnection(n['hidden'], n['hidden'], name='c3'))
# Using RNN, every steps gets different value of Neron
n.sortModules()
print n.activate([2, 2])
print n.activate([2, 2])
print n.activate([2, 2])
n.reset() # Clear n and Reset it
print n.activate([2, 2])
print n.activate([2, 2])
示例2: RecurrentNetwork
# 需要导入模块: from pybrain.structure import FeedForwardNetwork [as 别名]
# 或者: from pybrain.structure.FeedForwardNetwork import addRecurrentConnection [as 别名]
# print n.activate([1,2])
# print weights
# print in_to_hidden.params
""" -- RECURRENT NETWORK -- """
from pybrain.structure import RecurrentNetwork
n = RecurrentNetwork()
n.addInputModule(LinearLayer(2, name="in"))
n.addModule(SigmoidLayer(3, name="hidden"))
n.addOutputModule(LinearLayer(1, name="out"))
n.addConnection(FullConnection(n["in"], n["hidden"], name="c1"))
n.addConnection(FullConnection(n["hidden"], n["out"], name="c2"))
n.addRecurrentConnection(FullConnection(n["hidden"], n["hidden"], name="c3"))
n.sortModules()
# the result is different every time
# print n.activate((2,2))
# print n.activate((2,2))
# print n.activate((2,2))
# goes back to its original initialization state
n.reset()
# print n.activate((2,2))
# print n.activate((2,2))
# print n.activate((2,2))