# -*- coding: utf-8 -*- from pybrain.structure import FeedForwardNetwork from pybrain.structure import LinearLayer, SigmoidLayer from pybrain.structure import FullConnection #定义反馈神经网络 n = FeedForwardNetwork() #定义层 inLayer = LinearLayer(2) hiddenLayer = SigmoidLayer(3) outLayer = LinearLayer(1) n.addInputModule(inLayer) n.addModule(hiddenLayer) n.addOutputModule(outLayer) #定义连接 in_to_hidden = FullConnection(inLayer, hiddenLayer) hidden_to_out = FullConnection(hiddenLayer, outLayer) n.addConnection(in_to_hidden) n.addConnection(hidden_to_out) #使模型可用 n.sortModules() #使用模型 print n.activate([1, 2]) #打印模型结构 print n #打印模型参数 print in_to_hidden.params print hidden_to_out.params #或者 print n.params