We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
valid_curve.append(loss.item())
valid_curve
loss_val
epoch
batch_size
loss.item()
loss_val/len(valid_loader)
np.mean(valid_curve)
loss_val_epoch=loss_val/len(valid_loader)
The text was updated successfully, but these errors were encountered:
https://github.com/JansonYuan/Pytorch-Camp/blob/master/hello%20pytorch/lesson/lesson-21/loss_acc_weights_grad.py#L158
对的,原来的loss统计有问题,你的建议不错,158行已经修改,多谢~
Sorry, something went wrong.
No branches or pull requests
valid_curve.append(loss.item())
是在读取验证集的for循环的外面,所以最后的valid_curve
列表里面只有一个损失值(最后一次读取验证集数据得到的损失)。loss_val
时,打印的是一个epoch
里,每次读取batch_size
个验证集样本,来计算batch_size
个样本损失的均值loss.item()
,读多少次就计算多少个均值loss.item()
,这里读取了2次,之后将2次的均值求和得到loss_val
,这样打印的应该不是一个epoch
的损失均值把,应该是loss_val/len(valid_loader)
才对吧。np.mean(valid_curve)
只有一个数据,求均值还是最后一次读取的损失。loss_val_epoch=loss_val/len(valid_loader)
。之后都用loss_val_epoch。The text was updated successfully, but these errors were encountered: