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

transformer loss函数计算有误 #61

Open
ywbgithub opened this issue May 31, 2024 · 2 comments
Open

transformer loss函数计算有误 #61

ywbgithub opened this issue May 31, 2024 · 2 comments

Comments

@ywbgithub
Copy link

def forward(enc_inputs, dec_inputs):
"""前向网络
enc_inputs: [batch_size, src_len]
dec_inputs: [batch_size, trg_len]
"""
logits, _, _, _ = model(enc_inputs, dec_inputs[:, :-1], src_pad_idx, trg_pad_idx)

targets = dec_inputs[:, 1:].view(-1)
loss = loss_fn(logits, targets)

return loss
@ywbgithub
Copy link
Author

logit数组 【batch_size, *src_len, trg_vocab_size】
targets数组【batch_size, *src_len】
两个数组维数不一致,而且对这两个数组使用loss_fn 没有实际意义

1 similar comment
@ywbgithub
Copy link
Author

logit数组 【batch_size, *src_len, trg_vocab_size】
targets数组【batch_size, *src_len】
两个数组维数不一致,而且对这两个数组使用loss_fn 没有实际意义

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

1 participant