lasseuth1 / blood_bowl2

Applying Reinforcement Learning to Blood Bowl
3 stars 4 forks source link

Can't reproduce the result without any change #2

Closed greentec closed 5 years ago

greentec commented 5 years ago

Hello again. I first tried main.py but got this error.

Initializing blood bowl environment 0 ...
Initializing blood bowl environment 1 ...
Initializing blood bowl environment 2 ...
Initializing blood bowl environment 3 ...
Initializing blood bowl environment 4 ...
Initializing blood bowl environment 5 ...
Initializing blood bowl environment 6 ...
Initializing blood bowl environment 7 ...
Traceback (most recent call last):
  File "rarity_of_events/main.py", line 307, in <module>
    main()
  File "rarity_of_events/main.py", line 44, in main
    memory.spatial_obs[0].copy_(torch.from_numpy(spatial_obs).float())
RuntimeError: The expanded size of the tensor (28) must match the existing size (18) at non-singleton dimension 3.  Target sizes: [8, 11, 18, 28].  Tensor sizes: [8, 28, 11, 18].

Probably the number of channels should be 28, so I used np.transpose.

memory.spatial_obs[0].copy_(torch.from_numpy(np.transpose(spatial_obs,(0,2,3,1))).float())

But then I got this error.

Initializing blood bowl environment 0 ...
Initializing blood bowl environment 1 ...
Initializing blood bowl environment 2 ...
Initializing blood bowl environment 3 ...
Initializing blood bowl environment 4 ...
Initializing blood bowl environment 5 ...
Initializing blood bowl environment 6 ...
Initializing blood bowl environment 7 ...
Traceback (most recent call last):
  File "rarity_of_events/main.py", line 308, in <module>
    main()
  File "rarity_of_events/main.py", line 76, in main
    Variable(memory.non_spatial_obs[step]), available_actions)
  File "D:\blood_bowl2-master\rarity_of_events\pruned_hybrid.py", line 21, in act
    value, policy = self(spatial_inputs, non_spatial_input)
  File "C:\Anaconda\envs\ffai_pytorch\lib\site-packages\torch\nn\modules\module.py", line 493, in __call__
    result = self.forward(*input, **kwargs)
  File "D:\blood_bowl2-master\rarity_of_events\pruned_hybrid.py", line 115, in forward
    value = self.critic(concatenated)
  File "C:\Anaconda\envs\ffai_pytorch\lib\site-packages\torch\nn\modules\module.py", line 493, in __call__
    result = self.forward(*input, **kwargs)
  File "C:\Anaconda\envs\ffai_pytorch\lib\site-packages\torch\nn\modules\linear.py", line 92, in forward
    return F.linear(input, self.weight, self.bias)
  File "C:\Anaconda\envs\ffai_pytorch\lib\site-packages\torch\nn\functional.py", line 1406, in linear
    ret = torch.addmm(bias, input, weight.t())
RuntimeError: size mismatch, m1: [8 x 13337], m2: [4633 x 1] at ..\aten\src\TH/generic/THTensorMath.cpp:961

The problematic part seems to be the part that gives the tensor to the critic. So I changed 4633 to 13337.

# The outputs for 5v5
# self.critic = nn.Linear(4633, 1)
# self.actor = nn.Linear(4633, 908)
self.critic = nn.Linear(13337, 1)
self.actor = nn.Linear(13337, 908)

And I also changed insert part of main.py like this..

# insert the step taken into memory
memory.insert(step, torch.from_numpy(np.transpose(spatial_obs,(0,2,3,1))).float(), torch.from_numpy(non_spatial_obs).float(), torch.tensor(actions_policy), torch.tensor(values), reward, masks, available_actions)

So, I think that some part of the code should be modified so that the user who is the first to receive the repo can run it right away.

I display version information to avoid confusion. OS : Windows 10 Conda version : 4.3.30 Python : 3.6 Pytorch : 1.1.0

greentec commented 5 years ago

When I run it on two different computers, I need to make the above changes on one computer but this repo run it on the other computer without modification. It is very strange, but I will close this issue.