Hi!!!
I am looking for help because I have been stuck at this point for 3 days and I dont know what else to do.
I want to train a NN. In my code after all appropriate installations this error appears.
TypeError: unsupported operand type(s) for +: ‘int’ and ‘list’
I think that the code has no errors because I have find other similar codes in the internet and they did not have problem.
I believe that I dont have install the appropriate versions either from Python, either from Pytorch, something like that…
Can you help me identify and solve the problem?
Error :
<class ‘int’>
<class ‘list’>
Traceback (most recent call last):
File “maddpg_trainer.py”, line 151, in
main()
File “maddpg_trainer.py”, line 143, in main
agent = MADDPGAgentTrainer(state_shape, action_size, num_agents, writer=writer, random_seed=48, dirname=dirname, print_every=100, model_path=args.model)
File “C:\ML-Agents\Katorina\maddpg.py”, line 331, in init
for i in range(self.num_agents)]
File “C:\ML-Agents\Katorina\maddpg.py”, line 331, in
for i in range(self.num_agents)]
File “C:\ML-Agents\Katorina\maddpg.py”, line 86, in init
random_seed, fc1_units=self.config[‘FC1’], fc2_units=self.config[‘FC2’]
File “C:\ML-Agents\Katorina\models.py”, line 87, in init
self.fc2 = nn.Linear(fc1_units + action_size, fc2_units) TypeError: unsupported operand type(s) for +: ‘int’ and 'list’
Unfortunately, nothing works.
In the first case with this change : self.fc2 = nn.Linear([fc1_units] + action_size, fc2_units)
I get this error
File “C:\Users\Danae\Anaconda3\envs\effort7\lib\site-packages\torch\nn\modules\linear.py”, line 41, in init
self.weight = Parameter(torch.Tensor(out_features, in_features))
TypeError: ‘list’ object cannot be interpreted as an integer
and with this change self.fc2 = nn.Linear(fc1_units + action_size[0], fc2_units)
I get this error
File “C:\Users\Danae\Anaconda3\envs\effort7\lib\site-packages\torch\nn\modules\linear.py”, line 41, in init
self.weight = Parameter(torch.Tensor(out_features, in_features))
RuntimeError: CUDA error (35): CUDA driver version is insufficient for CUDA runtime version
Can you maybe print action_size. Just so I can see what this list contains.
Just do the same as you did with
but remove the type() so it’s just print(action_size) and post the result.
But judging from this error
it actually should have worked, but there might be a problem with CUDA or graphics driver version, or you are trying to use CUDA when you are supposed to use cpu (e.g. if you are on a cpu installation of pytorch or don’t have a compatible gpu)
I had also tried to install a previous version of pytorch because I believed that this was the reason of the errors.
Installing without CUDA conda install pytorch=0.4.1 -c pytorch
ok. I have no idea what action_size is supposed to be, but
will definitely work (as in, it will no longer give you this error)
As for this error message:
I am not quite sure. It could be multiply things. The only thing I could say from the top of my head is:
Are you maybe loading a model like so model = torch.load(pathname)?
If so, you might wanna try and include a map_location like so: model = torch.load(pathname, map_location=map_location)
For CPU (your case I am assuming) that would be: model = torch.load(pathname, map_location='cpu')