db09dc1fb503ab8f7de69fa23e8d38742bda8e90,ch07/03_dqn_double.py,,calc_values_of_states,#Any#Any#Any#,48
Before Change
def calc_values_of_states(states, net, cuda=False):
mean_vals = []
for batch in np.array_split(states, 64):
states_v = Variable(torch.from_numpy(batch), volatile=True)
if cuda:
states_v = states_v.cuda()
action_values_v = net(states_v)
best_action_values_v = action_values_v.max(1)[0]
mean_val = best_action_values_v.mean().data.cpu().numpy()[0]
mean_vals.append(mean_val)
return np.mean(mean_vals)
After Change
def calc_values_of_states(states, net, device="cpu"):
mean_vals = []
for batch in np.array_split(states, 64):
states_v = torch.tensor(batch).to(device)
action_values_v = net(states_v)
best_action_values_v = action_values_v.max(1)[0]
mean_vals.append(best_action_values_v.mean().item())
return np.mean(mean_vals)
In pattern: SUPERPATTERN
Frequency: 3
Non-data size: 13
Instances
Project Name: PacktPublishing/Deep-Reinforcement-Learning-Hands-On
Commit Name: db09dc1fb503ab8f7de69fa23e8d38742bda8e90
Time: 2018-04-27
Author: max.lapan@gmail.com
File Name: ch07/03_dqn_double.py
Class Name:
Method Name: calc_values_of_states
Project Name: PacktPublishing/Deep-Reinforcement-Learning-Hands-On
Commit Name: db09dc1fb503ab8f7de69fa23e8d38742bda8e90
Time: 2018-04-27
Author: max.lapan@gmail.com
File Name: ch07/07_dqn_distrib.py
Class Name:
Method Name: calc_values_of_states
Project Name: PacktPublishing/Deep-Reinforcement-Learning-Hands-On
Commit Name: b5e848af46b4a6fc21e718803dbf3d7c72afd72a
Time: 2018-04-27
Author: max.lapan@gmail.com
File Name: ch08/lib/common.py
Class Name:
Method Name: calc_values_of_states