k4ntz / NUDGE

Logic Reinforcement Learning
MIT License
15 stars 6 forks source link

env and run error fix #3

Closed zdx3578 closed 9 months ago

k4ntz commented 1 year ago

The python version we have used is 3.8 yes

zdx3578 commented 1 year ago

pip install torch ocatari

zdx3578 commented 1 year ago
python3 train.py -s 0 -alg logic -m getout -env getout  -r 'getout_human_assisted'

training environment name : Getout
Set all environment deterministic to seed 0
Traceback (most recent call last):
  File "src/train.py", line 343, in <module>
    main()
  File "src/train.py", line 86, in main
    env = gym.make(args.env, generator_args={"spawn_all_entities": False})
  File "/home/jz/miniconda3/envs/py38/lib/python3.8/site-packages/gym/envs/registration.py", line 569, in make
    _check_version_exists(ns, name, version)
  File "/home/jz/miniconda3/envs/py38/lib/python3.8/site-packages/gym/envs/registration.py", line 219, in _check_version_exists
    _check_name_exists(ns, name)
  File "/home/jz/miniconda3/envs/py38/lib/python3.8/site-packages/gym/envs/registration.py", line 197, in _check_name_exists
    raise error.NameNotFound(
gym.error.NameNotFound: Environment getout doesn't exist. 

     if args.m == "getout":
-        env = gym.make(args.env, generator_args={"spawn_all_entities": False})
+        # env = gym.make(args.env, generator_args={"spawn_all_entities": False})
+        env = create_getout_instance(enemies=True)

Candidate Clauses:
jump(X):-closeby(O1,O2),type(O1,agent),type(O2,enemy).
left_go_get_key(X):-not_have_key(X),on_left(O2,O1),type(O1,agent),type(O2,key).
right_go_get_key(X):-not_have_key(X),on_right(O2,O1),type(O1,agent),type(O2,key).
left_go_to_door(X):-have_key(X),on_left(O2,O1),type(O1,agent),type(O2,door).
right_go_to_door(X):-have_key(X),on_right(O2,O1),type(O1,agent),type(O2,door).
Started training at (GMT) :  1691463013.8131578
============================================================================================
  0%|                           | 0/800000 [00:00<?, ?it/s]Traceback (most recent call last):
  File "src/train.py", line 350, in <module>
    main()
  File "src/train.py", line 246, in main
    state = initialize_game(env, args)
  File "/home/jz/github/neuro-vector-symbolic-architectures-raven/LogicRL/src/utils.py", line 19, in initialize_game
    state = env.reset()
AttributeError: 'Getout' object has no attribute 'reset'
  0%|                           | 0/800000 [00:00<?, ?it/s]
zdx3578 commented 1 year ago
(py38) ➜  LogicRL git:(master) ✗ python3 src/play.py -s 0 -alg ppo -m getout
 -env getout  
Set all environment deterministic to seed 0
Loading
Traceback (most recent call last):
  File "src/play.py", line 141, in <module>
    main()
  File "src/play.py", line 86, in main
    model = load_model(model_file, args)
  File "src/play.py", line 23, in load_model
    model.actor.print_program()
  File "/home/jz/miniconda3/envs/py38/lib/python3.8/site-packages/torch/nn/modules/module.py", line 1614, in __getattr__
    raise AttributeError("'{}' object has no attribute '{}'".format(
AttributeError: 'MLPGetout' object has no attribute 'print_program'
(py38) ➜  LogicRL git:(master) ✗ 
zdx3578 commented 1 year ago

src/train.py -s 0 -alg logic -m threefish -env threefish -r threefish_bs_rf1 can run ok

k4ntz commented 9 months ago

I guess that this error is now fixed, I'm closing the issue.