k4ntz / NUDGE

Logic Reinforcement Learning
MIT License
15 stars 6 forks source link

question about HackAtari #8

Open Tianming40 opened 4 months ago

Tianming40 commented 4 months ago

Hi, I forked the master branch from Fixed the README. After I tried to run it, I started to get theModuleNotFoundError: No module named 'hackatari'error message. I tried to install it manually usingpip install hackatari, and then ran python train.pyagain. I got a problem with HackAtari initialization, as shown below. I saw that the game parameter was not provided during initialization. I wonder if this is related to the newly added features.

Traceback (most recent call last):
  File "train.py", line 242, in <module>
    main(**config)
  File "train.py", line 90, in main
    env = NudgeBaseEnv.from_name(environment, mode=algorithm, **env_kwargs)
  File "/Users/tianmingzhang/UNI/第八学期/explainableNudge/nudge/env.py", line 55, in from_name
    return env_module.NudgeEnv(**kwargs)
  File "in/envs/seaquest/env.py", line 25, in __init__
    self.env = HackAtari(env_name="ALE/Seaquest-v5", mode="ram",
TypeError: __init__() missing 1 required positional argument: 'game'

:) thx

k4ntz commented 4 months ago

Actually, for consistency with OCAtari, we now use env_name in both of them (instead of game). Please try to do: pip install -U ocatari hackatari # to update both packages. My configuration is:

> pip list | grep atari
hackatari                  0.0.4
ocatari                    1.1.6
Tianming40 commented 4 months ago

thx for the Guide. I have another question , is it possible , that we only try the policy reasoning module of NUDGE? when yes , how could I get the weight? :)

Tianming40 commented 4 months ago

thx for the Guide. I have another question , is it possible , that we only try the policy reasoning module of NUDGE? when yes , how could I get the weight? :)

i have tried python3 play.py -s 0 -alg logic -m getout -env getout but have gotten this error :

Traceback (most recent call last):
  File "play.py", line 6, in <module>
    from env_src.procgen.render import render_loot, render_ecoinrun, render_threefish
  File "/Users/tianmingzhang/UNI/第八学期/explainableNudge/env_src/procgen/render.py", line 16, in <module>
    font = ImageFont.truetype(font_path, size=40)
  File "/usr/local/anaconda3/envs/Nudge/lib/python3.8/site-packages/PIL/ImageFont.py", line 807, in truetype
    return freetype(font)
  File "/usr/local/anaconda3/envs/Nudge/lib/python3.8/site-packages/PIL/ImageFont.py", line 804, in freetype
    return FreeTypeFont(font, size, index, encoding, layout_engine)
  File "/usr/local/anaconda3/envs/Nudge/lib/python3.8/site-packages/PIL/ImageFont.py", line 244, in __init__
    self.font = core.getfont(
OSError: cannot open resource
k4ntz commented 4 months ago

Apparently you are lacking some font, have you installed the pip package ? You should try to use Atari environments, they should be working on any OS. To visualize the weights, you can look into this print_program function: https://github.com/k4ntz/NUDGE/blob/96d18f5c7ecf3b715307da5aed815df7c7df3894/nudge/utils.py#L115

hkrsnd commented 4 months ago

thx for the Guide. I have another question , is it possible , that we only try the policy reasoning module of NUDGE?

Yes, you can find the policy reasoning function here (the actor in the NsfrActorCritic class): https://github.com/k4ntz/NUDGE/blob/master/nudge/agents/logic_agent.py#L21

Tianming40 commented 3 months ago

thx for the Guide. I have another question , is it possible , that we only try the policy reasoning module of NUDGE?

Yes, you can find the policy reasoning function here (the actor in the NsfrActorCritic class): https://github.com/k4ntz/NUDGE/blob/master/nudge/agents/logic_agent.py#L21

thx so much for the answer, However, I still don't fully understand. Could I only try the reasoning part? If so, how could I obtain the pre-trained checkpoint? :)