grauwolf32 / openai-game

Handmade environments and trained models.
1 stars 0 forks source link

AttributeError: module 'baselines.common.tf_util' has no attribute 'get_session' #1

Open itzmestar opened 6 years ago

itzmestar commented 6 years ago

hi, I am trying to run run_acktr.py on python 3.6 but i get this error:

RESTART: C:\Users\abc\Desktop\openai\work\openai-game\python\run_acktr.py WARN: gym.spaces.Box autodetected dtype as <class 'numpy.float32'>. Please provide explicit dtype. WARN: gym.spaces.Box autodetected dtype as <class 'numpy.float32'>. Please provide explicit dtype. WARN: gym.spaces.Box autodetected dtype as <class 'numpy.float32'>. Please provide explicit dtype. WARN: gym.spaces.Box autodetected dtype as <class 'numpy.float32'>. Please provide explicit dtype. Logging to C:\Users\abc\AppData\Local\Temp\openai-2018-02-21-23-53-22-432413 WARN: Could not seed environment <GatheringGameEnv<1>> Use async eigen decomp updating 12 eigenvalue/vectors projecting 3 gradient matrices Use async eigen decomp updating 14 eigenvalue/vectors projecting 4 gradient matrices Traceback (most recent call last): File "C:\Users\abc\Desktop\openai\work\openai-game\python\run_acktr.py", line 62, in train(num_timesteps=args.num_timesteps, seed=args.seed, env_name=args.env, fname=args.fname) File "C:\Users\abc\Desktop\openai\work\openai-game\python\run_acktr.py", line 44, in train num_timesteps=num_timesteps, animate=visualization, fname=fname) File "C:\Users\abc\Desktop\openai\work\openai-game\python\acktr_cont.py", line 82, in learn enqueue_threads.extend(qr.create_threads(U.get_session(), coord=coord, start=True)) AttributeError: module 'baselines.common.tf_util' has no attribute 'get_session'

I have the latest openai/baselines code. I checked indeed 'baselines.common.tf_util' has make_session but no 'get_session' should I replace acktr_cont.py with the file from baselines??

grauwolf32 commented 6 years ago

Hello, In the old version of baselines i had this function:

def get_session():
    return tf.get_default_session()

I think, you can use tf.get_default_session() instead of U.get_session() I add some code to acktr_cont.py which can save/load model from checkpoints. If you don't want to make checkpoints, you can use acktr_cont.py from the baselines.

To run game simulation from checkpoint you can use ai_runner.py --fname ./model/gathering.ckpt Also i made little changes to baselines/acktr/policies.py, - in GaussianMlpPolicy i use tf.nn.elu activation function, instead of tf.nn.tanh. (Not sure that gathering.ckpt would work without this change)

itzmestar commented 6 years ago

thanks for the reply.

i got older version of baselines as well. running run_acktr.py with it gives another issue.

also i tried to run ai_runner.py which fails in module import: Traceback (most recent call last): File "ai_runner.py", line 7, in from micro_env import * ModuleNotFoundError: No module named 'micro_env'

I couldn't find this micro_env in pip either.

grauwolf32 commented 6 years ago

Check my latest commit, It should be working now (I made an update for latest versions of gym and baselines)

itzmestar commented 6 years ago

its working. thanks 👍