|
・In Japanese
■Description of BCELoss, MSELoss
Calculates the error function used in machine learning.
■Specific example using BCELoss, MSELoss
<Binary Cross Entropy Loss>
import torch
import torch.nn as nn
loss = nn.BCELoss()
estimate = torch.tensor([0.7,0.2,0.1]) # estimate value
real = torch.tensor([1.0, 0, 0]) # true value or target value
print(loss(estimate , real))
⇒ tensor(0.2284)
The calculation is below
<MSE:Mean Square Error>
The format is the same as above, changing the "BCE Loss" part to "MSE Loss".
import torch
import torch.nn as nn
loss = nn.MSELoss()
estimate = torch.tensor([0.7,0.2,0.1]) # estimate value
real = torch.tensor([1.0, 0, 0]) # true value or target value
print(loss(estimate , real))
⇒ tensor(0.0467)
The calculation is below
|
|