We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
I have an issue with the sortModules method throwing a KeyError.
Following the tutorial example, I created a script with the following:
#! /usr/bin/env python # -*- coding: utf-8 -*- import sys import scipy import numpy as np print "\nPython version: %s" % sys.version print "Numpy version: %s" % np.version.version print "Scipy version: %s" % scipy.version.version from pybrain.structure import FeedForwardNetwork from pybrain.structure import LinearLayer, SigmoidLayer from pybrain.structure import FullConnection # Create network nn = FeedForwardNetwork() # Set network parameters INPUT_NDS = 2 HIDDEN_NDS = 3 OUTPUT_NDS = 1 # Create Feed Forward Network layers inLayer = LinearLayer(INPUT_NDS) hiddenLayer = SigmoidLayer(HIDDEN_NDS) outLayer = LinearLayer(OUTPUT_NDS) # Fully connect all layers in_to_hidden = FullConnection(inLayer, hiddenLayer) hidden_to_out = FullConnection(hiddenLayer, outLayer) # Add the connected layers to the network nn.addConnection(in_to_hidden) nn.addConnection(hidden_to_out) # Sort modules to prepare the NN for use nn.sortModules()
Which gives me: Python version: 2.6.5 (r265:79063, Apr 16 2010, 13:57:41) [GCC 4.4.3] Numpy version: 1.3.0 Scipy version: 0.7.0 Traceback (most recent call last): File "/tmp/py7317Q6c", line 46, in nn.sortModules() File "/usr/local/lib/python2.6/dist-packages/PyBrain-0.3-py2.6.egg/pybrain/structure/networks/network.py", line 224, in sortModules self._topologicalSort() File "/usr/local/lib/python2.6/dist-packages/PyBrain-0.3-py2.6.egg/pybrain/structure/networks/network.py", line 188, in _topologicalSort graph[c.inmod].append(c.outmod) KeyError: <LinearLayer 'LinearLayer-3'>
I have the latest version of pybrain installed, so this seems strange. Especially as I when use the shortcut:
from pybrain.tools.shortcuts import buildNetwork
The text was updated successfully, but these errors were encountered:
You need to do nn.addModule(xLayer) for all the modules, before adding the connections.
Sorry, something went wrong.
Thanks for the quick reply. I guess I should read the documentation a little more closely! Sorry for the noob question and thanks for your help!
You're welcome!
No branches or pull requests
I have an issue with the sortModules method throwing a KeyError.
Following the tutorial example, I created a script with the following:
Which gives me:
Python version: 2.6.5 (r265:79063, Apr 16 2010, 13:57:41)
[GCC 4.4.3]
Numpy version: 1.3.0
Scipy version: 0.7.0
Traceback (most recent call last):
File "/tmp/py7317Q6c", line 46, in
nn.sortModules()
File "/usr/local/lib/python2.6/dist-packages/PyBrain-0.3-py2.6.egg/pybrain/structure/networks/network.py", line 224, in sortModules
self._topologicalSort()
File "/usr/local/lib/python2.6/dist-packages/PyBrain-0.3-py2.6.egg/pybrain/structure/networks/network.py", line 188, in _topologicalSort
graph[c.inmod].append(c.outmod)
KeyError: <LinearLayer 'LinearLayer-3'>
I have the latest version of pybrain installed, so this seems strange. Especially as I when use the shortcut:
The text was updated successfully, but these errors were encountered: