Hello everyone!

My question seems common but I have not found the solution yet…

I have implemented MADDPG algorithm and I receive this error message

RuntimeError: size mismatch, m1: [20 x 20], m2: [40 x 64] at …\aten\src\TH/generic/THTensorMath.cpp:41

This is the code

class Actor(nn.Module):

`def __init__(self, state_size, action_size, seed, fc1_units=400, fc2_units=300, use_bn=False): super(Actor, self).__init__() self.seed = torch.manual_seed(seed) self.use_bn = use_bn self.fc1 = nn.Linear(state_size, fc1_units) self.fc2 = nn.Linear(fc1_units, fc2_units) self.fc3 = nn.Linear(fc2_units, action_size) if self.use_bn: self.bn1 = nn.BatchNorm1d(state_size) self.bn2 = nn.BatchNorm1d(fc1_units) self.bn3 = nn.BatchNorm1d(fc2_units) self.reset_parameters()`

def forward(self, state):

`print('state shape',state.shape) if self.use_bn: x = self.fc1(self.bn1(state)) else: x = self.fc1(state) x = F.relu(x) if self.use_bn: x = self.bn2(x) x = self.fc2(x) x = F.relu(x) if self.use_bn: x = self.bn3(x) return F.relu(self.fc3(x))`

class Critic(nn.Module):

`def __init__(self, state_size, action_size, seed, fc1_units=400, fc2_units=300, use_bn=False): super(Critic, self).__init__() self.seed = torch.manual_seed(seed) self.use_bn = use_bn self.fc1 = nn.Linear(state_size, fc1_units) self.fc2 = nn.Linear(fc1_units + action_size, fc2_units) self.fc3 = nn.Linear(fc2_units, 1) if self.use_bn: self.bn1 = nn.BatchNorm1d(fc1_units) self.bn2 = nn.BatchNorm1d(fc2_units)`

def forward(self, state, action):

x = self.fc1(state)

xs = F.relu(x)

if self.use_bn:

x = self.bn1(x)

x = torch.cat((xs, action), dim=1)

x = self.fc2(x)

x = F.relu(x)

if self.use_bn:

x = self.bn2(x)

return self.fc3(x)

The error is when I call this

Q = self.critic(states, actions)

states = 10

actions = 10

Can someone help me!!!