berkeleydeeprlcourse / homework

Assignments for CS294-112.
MIT License
1.56k stars 1.04k forks source link

AttributeError for get_wrapper_by_name(env, "Monitor") in hw3 #2

Closed hungtuchen closed 7 years ago

hungtuchen commented 7 years ago
---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
<ipython-input-12-005c8955d609> in <module>()
     12     frame_history_len=4,
     13     target_update_freq=10000,
---> 14     grad_norm_clipping=10
     15 )

/Users/mac/Projects/ml-playground/reinforcement/deep_q_learning.py in dqn_learing(env, q_func, optimizer_spec, exploration, stopping_criterion, replay_buffer_size, batch_size, gamma, learning_starts, learning_freq, frame_history_len, target_update_freq, grad_norm_clipping)
    135     for t in count():
    136         ### Check stopping criterion
--> 137         if stopping_criterion is not None and stopping_criterion(env, t):
    138             break
    139 

<ipython-input-11-ab71394a8fd6> in stopping_criterion(env, t)
      2         # notice that here t is the number of steps of the wrapped env,
      3         # which is different from the number of steps in the underlying env
----> 4         return get_wrapper_by_name(env, "Monitor").get_total_steps() >= num_timesteps

AttributeError: '_Monitor' object has no attribute 'get_total_steps'
AttributeError                            Traceback (most recent call last)
<ipython-input-9-005c8955d609> in <module>()
     12     frame_history_len=4,
     13     target_update_freq=10000,
---> 14     grad_norm_clipping=10
     15 )

/Users/mac/Projects/ml-playground/reinforcement/deep_q_learning.py in dqn_learing(env, q_func, optimizer_spec, exploration, stopping_criterion, replay_buffer_size, batch_size, gamma, learning_starts, learning_freq, frame_history_len, target_update_freq, grad_norm_clipping)
    201 
    202         ### 4. Log progress
--> 203         episode_rewards = get_wrapper_by_name(env, "Monitor").get_episode_rewards()
    204         if len(episode_rewards) > 0:
    205             mean_episode_reward = np.mean(episode_rewards[-100:])

AttributeError: '_Monitor' object has no attribute 'get_episode_rewards'

Seems like whenever I can't get any specified attributes when calling get_wrapper_by_name(env, "Monitor")

I have update gym version, but it didn't work out.

cbfinn commented 7 years ago

Make sure you have the latest version of gym cloned from the master branch on git, not the pip version.

hungtuchen commented 7 years ago

Thanks, it was solved when I used master branch from git repo