Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

LSTM反向传播 #24

Open
ghost opened this issue May 31, 2023 · 3 comments
Open

LSTM反向传播 #24

ghost opened this issue May 31, 2023 · 3 comments

Comments

@ghost
Copy link

ghost commented May 31, 2023

你好,我想问一下就是最后求权重梯度的。

1.我的各个门的输出变量的维度是(batchsize,hiddensize),输入变量x的维度是(batchsize,inputsize),因为我有batchsize嘛,所以想batchsize中的每个样本单独计算,但是现在的维度并不一致。δ(t)C⊙C(t−1)⊙f(t)⊙(1−f(t))计算完的维度是(hiddensize),然而,h(t−1)的维度也是(hiddensize),(h(t−1))T转置之后的维度是(1,hiddensize),这样进行矩阵乘法后,计算出来的维度是1,但我的Wfh的维度是(hiddensize,hiddensize)啊,后来对于这个问题,我用δ(t)C⊙C(t−1)⊙f(t)⊙(1−f(t)) * h(t−1).unsqueeze(dim=1),这样维度对了,请问这样可以嘛?

2.当为计算Wfx的维度的时候,δ(t)C⊙C(t−1)⊙f(t)⊙(1−f(t))计算完的维度是(hiddensize),然而,x(t)的维度是(inputsize),两者又出现不一致的情况,我又将矩阵乘法改成了δ(t)C⊙C(t−1)⊙f(t)⊙(1−f(t)).unsqueeze(dim=1) * x(t).unsqueeze(dim=0),不知道这样写严不严谨?

希望能得到您的帮助

@gengyp
Copy link

gengyp commented May 31, 2023 via email

@wangzhongqing
Copy link

wangzhongqing commented May 31, 2023 via email

@K-fall
Copy link

K-fall commented May 31, 2023 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants