【发布时间】:2020-05-17 20:04:01
【问题描述】:
在使用 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
谁能帮我打个招呼……
【问题讨论】:
-
什么是单层RNNN
-
@prosti 单层 RNN 表示单层神经元,其中第一个神经元的每个输出都是第二个神经元的输入,并且序列继续。
标签: python pytorch typeerror recurrent-neural-network