RuntimeError: mat1 and mat2 shapes cannot be multiplied (64x1 and 3x256)
happens at this line:
x = F.relu(self.linear1(state))
class Critic(nn.Module): def __init__(self, state_size, action_size, hidden_size, output_size): super(Critic, self).__init__() self.linear1 = nn.Linear(state_size, hidden_size) self.linear2 = nn.Linear(hidden_size+action_size, hidden_size) self.linear3 = nn.Linear(hidden_size, output_size) def forward(self, state, action): x = F.relu(self.linear1(state)) x = torch.cat([x, action], dim = 1) x = F.relu(self.linear2(x)) #x = F.relu(self.linear2(x)) x = self.linear3(x) return x
and that 64 depends on the
def sample(self, batch_size): state_batch =  action_batch =  reward_batch =  next_state_batch =  done_batch =  batch = random.sample(self.buffer, batch_size) for experience in batch: state, action, reward, next_state, done = experience state_batch.append(state) action_batch.append(action) reward_batch.append(reward) next_state_batch.append(next_state) done_batch.append(done) return state_batch, action_batch, reward_batch, next_state_batch, done_batch
does anyone know how this error can be fixed?