输入x多一个维度,输出差距怎么那么大?
import torch
import numpy as np
x = torch.randn((64,224,224))
y = torch.rand((64,224,224))
y = (y > 0.5).float()
y = torch.tensor(y)
fun = torch.nn.CrossEntropyLoss()
print(fun(x,y)) //输出:tensor(661.5663)
import torch
import numpy as np
x = torch.randn((64,2,224,224))
y = torch.rand((64,224,224))
y = (y > 0.5).float()
y = torch.tensor(y).to(torch.long)
fun = torch.nn.CrossEntropyLoss()
print(fun(x,y)) //输出:tensor(0.9030)
标签:tensor,torch,CrossEntropyLoss,64,import,224
From: https://www.cnblogs.com/gitLab/p/17756013.html