项目场景:
pytorch训练gan时报错
问题描述:
CUDA error: CUBLAS_STATUS_ALLOC_FAILED when calling 'cublasCreate(handle)`
原因分析:
D网络输出层没有经过sigmoid,但是损失函数用了 criterion = nn.BCELoss()
解决方案:
损失函数改用criterion = nn.BCEWithLogitsLoss()
;
注意网络的输出;
ps:平时训练网络时推荐使用nn.BCEWithLogitsLoss()