@@ -0,0 +1,1439 @@
+import gym%0Aimport numpy as np%0Aimport torch%0Aimport os%0Aimport matplotlib.pyplot as plt%0Afrom torch.autograd import Variable%0Aos.chdir('/home/lamsadeuser/resnets_atari')%0A%0Afrom utils import select_action%0Afrom ImageAtari import wrap_dqn%0A%0Adef Q_val(model):%0A    %22%22%22Plot the Q_value for each action while playing one game%0A    You have to load a model first and pass it as an argument to the function%0A    %0A    Example %0A    model = torch.load('model_atari_Seaquest_dqn.pkl')%0A    Q_val(model)%22%22%22%0A    game = input(%22What game ? %22)%0A    env = gym.make(game + %22NoFrameskip-v4%22)%0A    env.reset()%0A    env = wrap_dqn(env,True)%0A    x = env.action_space%0A    for i in range(18,0,-1):%0A        if x.contains(i):%0A            nb_actions = (i+1)%0A            break%0A    Ql = %5B%5B%5D for _ in range(nb_actions)%5D%0A    env.render()%0A    state = env.reset()%0A    state = torch.from_numpy(np.array(state))%0A    state = state.transpose(0,2).transpose(1,2).unsqueeze(0)%0A    nb_frames = 18000%0A    done = False%0A    while not done and nb_frames %3E 0:%0A        env.render()%0A        action=select_action(state, 0, model, 6)%0A        state, reward, done, _ = env.step(action%5B0,0%5D)%0A        state = torch.from_numpy(np.array(state))%0A        state = state.transpose(0,2).transpose(1,2).unsqueeze(0)%0A        Q = model(Variable(state))%0A        for i,L in enumerate(Ql):%0A            inpu = Q.data.squeeze()%5Bi%5D%0A            L.append(inpu)%0A            plt.plot(L)%0A        plt.show()%0A        nb_frames-=1%0A

Create Q_values.py