Skip to content
New issue

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

Not compatible with PyBrain 0.3.1 #15

Open
NicholasWalton opened this issue Apr 1, 2012 · 2 comments
Open

Not compatible with PyBrain 0.3.1 #15

NicholasWalton opened this issue Apr 1, 2012 · 2 comments

Comments

@NicholasWalton
Copy link

PyBrain 0.3 works fine.

Procedure:
Install PyBrain 0.3.1
Run test_pybrainbridge.py

Expected result:
All tests pass

Observed result:
13 tests fail with identical exceptions.

======================================================================
ERROR: testCopyable (__main__.TestNetworkEquivalence)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/nicholas/src/arac/src/python/arac/tests/test_pybrainbridge.py", line 348, in testCopyable
    copied = net.copy()
  File "/home/nicholas/src/arac/src/python/arac/pybrainbridge.py", line 266, in copy
    result.sortModules()
  File "/home/nicholas/src/pybrain/pybrain/structure/networks/recurrent.py", line 137, in sortModules
    super(RecurrentNetworkComponent, self).sortModules()
  File "/home/nicholas/src/arac/src/python/arac/pybrainbridge.py", line 274, in sortModules
    super(_Network, self).sortModules()
  File "/home/nicholas/src/pybrain/pybrain/structure/networks/network.py", line 259, in sortModules
    Module.__init__(self, self.indim, self.outdim, name=self.name)
  File "/home/nicholas/src/pybrain/pybrain/structure/modules/module.py", line 51, in __init__
    self._resetBuffers()
  File "/home/nicholas/src/pybrain/pybrain/structure/networks/network.py", line 263, in _resetBuffers
    super(Network, self)._resetBuffers(length)
  File "/home/nicholas/src/pybrain/pybrain/structure/modules/module.py", line 58, in _resetBuffers
    self.offset = 0
AttributeError: can't set attribute
@o-v-o
Copy link

o-v-o commented Jun 12, 2013

I had this problem a while ago. I guess it happens because the attribute offset of the module class is replaced by a property in the arac wrapper class _Network ( which is in the file pybrainbridge.py) and this property is read only i.e. has no setter. I added a setter

    @offset.setter
    def offset(self, value):
        pass

below the following lines of code in _Network:

    @property
    def offset(self):
        return self.proxies[self].timestep()

This fixed the AttributeError regarding offset for me and I was able to train networks, but I hardly used pybrain and arac and therefore have not tested if an empty setter does not break certain parts of pybrain <-> arac interaction, but maybe someone might find this info helpful.

@ypxie
Copy link

ypxie commented Feb 17, 2016

add a function to component.cpp

void
Component::set_timestep(int value)
{
    _timestep = value;
    return ;
}

add the function declaration in component.h

then in pybrainbridge.py

add the following :

    @property
    def offset(self):
        return self.proxies.handle(self).timestep()

    @offset.setter
    def offset(self, value):  
        self.proxies.handle(self).set_timestep(int(value))

the original self.proxies(self) does not work.

Then the uncompatibility should be fixed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants