nn.CrossEntropyLoss

刚开始报错

TypeError: forward() got an unexpected keyword argument 'reduction'

查了半天后发现是写错地方了,原来是这么写的

criterion = nn.CrossEntropyLoss(weight=weights)
loss = criterion(x, y, reduction='sum'

你可能感兴趣的:(python,keras,深度学习)