So, this mis-match would indicate that state_size is different from what you expected. I assume that state_batch is a Tensor of shape 64x1? But expect it to be 64x3?
Also, if you’re expecting a Tensor to be passed in, shouldn’t you use torch.stack to covert the list of Tensors to a single Tensor which can be passed in batch? Could you check the type and shape of state_batch?
What are the contents of the list? Are they Tensors? If so, what shape? If the elements are of shape [1,3] and you have a list of 64 items, you can stack the list of Tensors into a single Tensor which might solve the mis-match error!
Could you print what state_batch[0].shape returns?
elements of state_batch list are state. They are numbers (scalars). Below is the full stack error. And part of update function that is referring to:
Traceback (most recent call last):
File "main.py", line 34, in <module>
agent.update(batch_size)
File "ddpg.py", line 62, in update
Qvals = self.critic.forward(states, actions)
File "model.py", line 56, in forward
x = F.relu(self.linear1(state))
RuntimeError: mat1 and mat2 shapes cannot be multiplied (64x1 and 3x128)
So, if state is a batch of scalars, it makes sense why you’re getting a mis-match within x = F.relu(self.linear1(state)), perhaps change self.linear1 to be of size [1, 128]? rather than [3,128]?
change the state_size to 1 rather than 3 will make it pass through that layer. If you’re sure the state_size is 3, then the issue lies with state instead
So, state_batch is a list of 64 elements which are purely scalars? So, state_batch[0].shape would return 1? If that’s true, and you’re sure state_size is 3 then something’s wrong with the state_batch variable!