class Actor(nn.Module):
def __init__(self, 6, 20, 6):
super(Actor, self).__init__()
self.linear1 = nn.Linear(6, 20)
self.linear2 = nn.Linear(20, 20)
self.linear3 = nn.Linear(20, 6)
def forward(self, s):
x = F.relu(self.linear1(s))
x = F.relu(self.linear2(x))
x = torch.tanh(self.linear3(x))
return x
以上为原神经网络
我现在有一个数组为limit = [1,2,3,4,5,6]
class Actor(nn.Module):
def __init__(self, 6, 20, 6):
super(Actor, self).__init__()
self.linear1 = nn.Linear(6, 20)
self.linear2 = nn.Linear(20, 20)
self.linear3 = nn.Linear(20, 6)
def forward(self, s, limit):
x = F.relu(self.linear1(s))
x = F.relu(self.linear2(x))
x = torch.tanh(self.linear3(x))
x = np.multiply(limit,action)
return x
我想变成这样 结果会报错 求各位大佬告知应如何修改