neat-gym icon indicating copy to clipboard operation
neat-gym copied to clipboard

Issue with discrete action spaces

Open pablogranolabar opened this issue 3 years ago • 0 comments

Hi again Simon!

I am trying to use neat-gym with some of the Gym toy text examples that are based on discrete action spaces, but I'm having some issues. From my limited understanding of neat-gym it inherits the observation and action space from the registered Gym environment, but I am getting the following errors whenever I attempt to use neat-gym with any of the discrete valued Gym environments:

$pablo python3 neat-evolve.py --eshyper config/frozenlake

 ****** Running generation 0 ****** 

/usr/lib/python3/dist-packages/requests/__init__.py:89: RequestsDependencyWarning: urllib3 (1.26.6) or chardet (4.0.0) doesn't match a supported version!
  warnings.warn("urllib3 ({}) or chardet ({}) doesn't match a supported "
multiprocessing.pool.RemoteTraceback: 
"""
Traceback (most recent call last):
  File "/usr/lib/python3.8/multiprocessing/pool.py", line 125, in worker
    result = (True, func(*args, **kwds))
  File "/home/pablo/Documents/development/frozenlake/neat-gym/neat-evolve.py", line 438, in eval_genome
    return config.eval_net_mean(net, genome)
  File "/home/pablo/Documents/development/frozenlake/neat-gym/neat-evolve.py", line 182, in eval_net_mean
    else self.eval_net_mean_reward(net, genome))
  File "/home/pablo/Documents/development/frozenlake/neat-gym/neat-evolve.py", line 191, in eval_net_mean_reward
    reward, steps = eval_net(net,
  File "/home/pablo/Documents/development/frozenlake/neat-gym/neat_gym/__init__.py", line 123, in eval_net
    action = net.activate(state)
  File "/home/pablo/.local/lib/python3.8/site-packages/neat/nn/recurrent.py", line 27, in activate
    if len(self.input_nodes) != len(inputs):
TypeError: object of type 'int' has no len()
"""

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

Traceback (most recent call last):
  File "/home/pablo/Documents/development/frozenlake/neat-gym/neat-evolve.py", line 766, in <module>
    main()
  File "/home/pablo/Documents/development/frozenlake/neat-gym/neat-evolve.py", line 759, in main
    winner = pop.run(pe.evaluate, config.ngen, args.maxtime)
  File "/home/pablo/Documents/development/frozenlake/neat-gym/neat-evolve.py", line 471, in run
    fitness_function(list(self.population.items()), self.config)
  File "/home/pablo/.local/lib/python3.8/site-packages/neat/parallel.py", line 30, in evaluate
    genome.fitness = job.get(timeout=self.timeout)
  File "/usr/lib/python3.8/multiprocessing/pool.py", line 771, in get
    raise self._value
TypeError: object of type 'int' has no len()
$pablo python3 neat-evolve.py config/frozenlake

Traceback (most recent call last):
  File "/home/pablo/Documents/development/frozenlake/neat-gym/neat-evolve.py", line 766, in <module>
    main()
  File "/home/pablo/Documents/development/frozenlake/neat-gym/neat-evolve.py", line 736, in main
    config = _GymNeatConfig(args)
  File "/home/pablo/Documents/development/frozenlake/neat-gym/neat-evolve.py", line 109, in __init__
    num_inputs = env.observation_space.shape[0]
IndexError: tuple index out of range

I've tried a couple of the other envs that utilize spaces.Discrete, all with the same type of error. Any ideas?

pablogranolabar avatar Sep 03 '21 08:09 pablogranolabar