Git Product home page Git Product logo

hebbianmetalearning's People

Contributors

enajx avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

hebbianmetalearning's Issues

Multiprocessing Error

Hi, I am currently trying to run train_hebb.py to reproduce the CarRacing-V0 results.
After training, it reports the error:

Traceback (most recent call last):
  File "C:\Users\17033\anaconda3\envs\metaplasticity\lib\site-packages\gym\envs\classic_control\rendering.py", line 185, in __del__
  File "train_hebb.py", line 51, in <module>
    main(sys.argv)
  File "train_hebb.py", line 45, in main
    self.close()
  File "C:\Users\17033\anaconda3\envs\metaplasticity\lib\site-packages\gym\envs\classic_control\rendering.py", line 99, in close
    es.run(args.generations, print_step=args.print_every, path=args.folder)
  File "C:\Users\17033\isef2022\HebbianMetaLearning\evolution_strategy_hebb.py", line 338, in run
    rewards = self._get_rewards_coevolved(pool, population, population_coevolved)                       # Compute population fitness:  Step 6
  File "C:\Users\17033\isef2022\HebbianMetaLearning\evolution_strategy_hebb.py", line 268, in _get_rewards_coevolved
    if self.isopen and sys.meta_path:
AttributeError: 'Viewer' object has no attribute 'isopen'
    rewards  = pool.map(worker_process_hebb_coevo, worker_args)
  File "C:\Users\17033\anaconda3\envs\metaplasticity\lib\multiprocessing\pool.py", line 364, in map
    return self._map_async(func, iterable, mapstar, chunksize).get()
  File "C:\Users\17033\anaconda3\envs\metaplasticity\lib\multiprocessing\pool.py", line 771, in get
    raise self._value
multiprocessing.pool.MaybeEncodingError: Error sending result: '<multiprocessing.pool.ExceptionWithTraceback object at 0x000001B99E91F580>'. Reason: 'Value
Error('ctypes objects containing pointers cannot be pickled')'

I also get another error, that repeats multiple times.

Traceback (most recent call last):
  File "C:\Users\17033\anaconda3\envs\metaplasticity\lib\site-packages\gym\envs\classic_control\rendering.py", line 185, in __del__
    self.close()
  File "C:\Users\17033\anaconda3\envs\metaplasticity\lib\site-packages\gym\envs\classic_control\rendering.py", line 99, in close
    if self.isopen and sys.meta_path:
AttributeError: 'Viewer' object has no attribute 'isopen'
Exception ignored in: <function Viewer.__del__ at 0x000002D4C87F5AF0>

Although, I am not sure if the two errors are related in anyway. I suspect that the errors are due to my package versions.

Package             Version
------------------- ---------
arviz               0.11.2
Bottleneck          1.3.5
Box2D               2.3.10
box2d-py            2.3.5
certifi             2022.9.24
cffi                1.15.1
cftime              1.5.1.1
cloudpickle         2.2.0
cycler              0.11.0
Cython              0.29.32
fonttools           4.25.0
glfw                2.5.5
gym                 0.21.0
imageio             2.22.2
importlib-metadata  5.0.0
importlib-resources 5.10.0
kiwisolver          1.4.2
llvmlite            0.39.1
lockfile            0.12.2
lz4                 4.0.2
matplotlib          3.5.2
mkl-fft             1.3.1
mkl-random          1.2.2
mkl-service         2.4.0
munkres             1.1.4
netCDF4             1.5.7
numba               0.56.3
numexpr             2.8.3
numpy               1.23.4
opencv-python       4.6.0.66
packaging           21.3
pandas              1.4.4
Pillow              9.2.0
pip                 22.2.2
pybullet            3.2.5
pycparser           2.21
pyglet              1.5.27
pyparsing           3.0.9
pystan              2.19.1.1
python-dateutil     2.8.2
pytz                2022.1
scipy               1.9.1
setuptools          65.4.0
six                 1.16.0
torch               1.12.1
typing_extensions   4.3.0
wheel               0.37.1
wincertstore        0.2
xarray              0.20.1
zipp                3.10.0

Here are my package versions.

Facing out of bound array error

I am trying to reproduce the results of the Car Racing task
When I do python train_hebb.py --environment CarRacing-v2
I get the following error:
image

stack underflow error

Hi. I am trying to reproduce the CarRacing-V0 results with the following commands:
CUDA_VISIBLE_DEVICES=5 python train_hebb.py --environment CarRacing-v0 --threads 10

Then it reports the error:

........................................................................

Initilisating Hebbian ES for CarRacing-v0 with ABCD_lr Hebbian rule


........................................................................

 ??(????(??? Starting Evolution ?(????(??? ? 

Run: 1665985483

........................................................................

multiprocessing.pool.RemoteTraceback: 
"""
Traceback (most recent call last):
  File "/home/zj/anaconda3/envs/hebbian2/lib/python3.8/multiprocessing/pool.py", line 125, in worker
    result = (True, func(*args, **kwds))
  File "/home/zj/anaconda3/envs/hebbian2/lib/python3.8/multiprocessing/pool.py", line 48, in mapstar
    return list(map(*args))
  File "/data2/zj/HebbianMetaLearning/evolution_strategy_hebb.py", line 48, in worker_process_hebb_coevo
    r = get_reward_func( hebb_rule,  eng,  init_weights, coeffs, coevolved_parameters) + decay
  File "/data2/zj/HebbianMetaLearning/fitness_functions.py", line 173, in fitness_hebb
    observation, reward, done, info = env.step(action)
  File "/home/zj/anaconda3/envs/hebbian2/lib/python3.8/site-packages/gym/core.py", line 263, in step
    observation, reward, done, info = self.env.step(action)
  File "/home/zj/anaconda3/envs/hebbian2/lib/python3.8/site-packages/gym/core.py", line 263, in step
    observation, reward, done, info = self.env.step(action)
  File "/home/zj/anaconda3/envs/hebbian2/lib/python3.8/site-packages/gym/wrappers/time_limit.py", line 16, in step
    observation, reward, done, info = self.env.step(action)
  File "/home/zj/anaconda3/envs/hebbian2/lib/python3.8/site-packages/gym/envs/box2d/car_racing.py", line 323, in step
    self.state = self.render("state_pixels")
  File "/home/zj/anaconda3/envs/hebbian2/lib/python3.8/site-packages/gym/envs/box2d/car_racing.py", line 399, in render
    self.render_indicators(WINDOW_W, WINDOW_H)
  File "/home/zj/anaconda3/envs/hebbian2/lib/python3.8/site-packages/gym/envs/box2d/car_racing.py", line 469, in render_indicators
    self.score_label.draw()
  File "/home/zj/anaconda3/envs/hebbian2/lib/python3.8/site-packages/pyglet/text/layout.py", line 898, in draw
    self._batch.draw()
  File "/home/zj/anaconda3/envs/hebbian2/lib/python3.8/site-packages/pyglet/graphics/__init__.py", line 557, in draw
    func()
  File "/home/zj/anaconda3/envs/hebbian2/lib/python3.8/site-packages/pyglet/text/layout.py", line 539, in unset_state
    glPopAttrib()
  File "/home/zj/anaconda3/envs/hebbian2/lib/python3.8/site-packages/pyglet/gl/lib.py", line 107, in errcheck
    raise GLException(msg)
pyglet.gl.lib.GLException: b'stack underflow'
"""

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "train_hebb.py", line 51, in <module>
    main(sys.argv)
  File "train_hebb.py", line 45, in main
    es.run(args.generations, print_step=args.print_every, path=args.folder)
  File "/data2/zj/HebbianMetaLearning/evolution_strategy_hebb.py", line 344, in run
    rewards = self._get_rewards_coevolved(pool, population, population_coevolved)                       # Compute population fitness:  Step 6   
  File "/data2/zj/HebbianMetaLearning/evolution_strategy_hebb.py", line 272, in _get_rewards_coevolved
    rewards  = pool.map(worker_process_hebb_coevo, worker_args)
  File "/home/zj/anaconda3/envs/hebbian2/lib/python3.8/multiprocessing/pool.py", line 364, in map
    return self._map_async(func, iterable, mapstar, chunksize).get()
  File "/home/zj/anaconda3/envs/hebbian2/lib/python3.8/multiprocessing/pool.py", line 771, in get
    raise self._value
pyglet.gl.lib.GLException: b'stack underflow'

No errors are reported when I set --threads to 1, so it seems that there is something wrong when env's render and multiprocessing are used together. Do you have any idea? Here's my pip list (I use python 3.8):

akro                         0.0.8
astunparse                   1.6.3
atari-py                     0.2.6
Box2D                        2.3.10
certifi                      2022.9.24
cloudpickle                  1.3.0
cma                          2.7.0
contourpy                    1.0.5
cycler                       0.11.0
Deprecated                   1.2.13
dm-tree                      0.1.6
dowel                        0.0.3
flatbuffers                  2.0
fonttools                    4.37.4
future                       0.18.2
garage                       2021.3.0
gast                         0.4.0
google-pasta                 0.2.0
gym                          0.17.1
gym-notices                  0.0.8
importlib-metadata           5.0.0
keras                        2.7.0
Keras-Preprocessing          1.1.2
kiwisolver                   1.4.4
libclang                     12.0.0
llvmlite                     0.32.1
matplotlib                   3.2.1
mkl-fft                      1.3.1
mkl-random                   1.2.2
mkl-service                  2.4.0
numba                        0.49.0
numpy                        1.23.1
opencv-python                4.2.0.34
opt-einsum                   3.3.0
packaging                    21.3
Pillow                       9.2.0
pip                          22.2.2
pybullet                     2.6.6
pyglet                       1.5.0
pyparsing                    3.0.9
python-dateutil              2.8.2
ray                          1.9.0
redis                        4.0.2
scipy                        1.8.1
setproctitle                 1.2.2
setuptools                   63.4.1
six                          1.16.0
tabulate                     0.8.9
tensorboard-data-server      0.6.1
tensorflow                   2.7.0
tensorflow-estimator         2.7.0
tensorflow-io-gcs-filesystem 0.23.1
tensorflow-probability       0.15.0
termcolor                    1.1.0
torch                        1.6.0
torchvision                  0.8.2
typing_extensions            4.4.0
wheel                        0.37.1
zipp                         3.9.0

I suspect it's caused by package versions. Can you provide the detailed versions of python, gym, pyglet and opencv-python? Thanks a lot.

How to plot the weights of the neural network

Thanks for your nice work!

But, how to plot the weights of the neural network in the paper(Figure1), the image is just like a QR code.

Can you tell me how or give me some key words to search for google?

bias in the linear layer

Hi!
I really curious to know why biases are disabled in all layers (Linear, CNN). What's the reason behind that? There is D_w in hebbian update rule, but, as i understand, that's not the same. It affects weights, not activations.

Can this hurt perfomance? Can we adapt hebbian rule to network biases? Or there is no need and i am missing something.

Thanks!

MemoryError

Thanks for your great work.

However while I run your code, I encountered a MemoryError.

...
    File ".../evolution_strategy_hebb.py", line 219, in _get_population
        return np.array(population).astype(np.float32)
numpy.core._exceptions.MemoryError: Unable to allocate 697. MiB for an array with shape (200, 91328, 5) and data type float64

At first, es.run doesn't show any problem but after several iterations, train_hebb.py occupy too much memory and the system break down because there is no memory left.

I already tried the solution below but it doesn't solve my error.
https://stackoverflow.com/questions/57507832/unable-to-allocate-array-with-shape-and-data-type

I also tried changing --threads argument from -1 to small integer but the system eventually slow down anyway.

I will keep trying several ways and If I find any solution, I will update this issue.

If you have any solution to solve MemoryError problem, please give me any advise.

Thank you in advance.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.