在使用Pytorch nn.linear函数制作简单的RNN时。所以首先我将权重初始化为
self.W_x = nn.Linear(self.input_dim, self.hidden_dim, bias=True)
self.W_h = nn.Linear(self.hidden_dim, self.hidden_dim, bias=True)
现在在主要步骤中,使用此代码语句使用先前的状态和权重的值来获取当前状态的结果
h_t = np.tanh((inp * self.W_x) + (prev_h * self.W_h))
所以在这里我得到python错误,如下所示
TypeError: mul(): argument 'other' (position 1) must be Tensor, not Linear
谁能帮我的忙...