Created
December 7, 2017 03:10
-
-
Save ciela/46358d5636d319978b336e84894846b5 to your computer and use it in GitHub Desktop.
Multi-label Classification 用のロス比較2(全て同じ結果にはなる)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import torch | |
from torch import nn as nn | |
from torch import autograd as ag | |
data = ag.Variable(torch.Tensor(torch.randn([100, 100]))) | |
labels = ag.Variable(torch.Tensor(torch.randn([100, 100]))) | |
multi_label_soft_margin = nn.MultiLabelSoftMarginLoss() | |
print(multi_label_soft_margin(data, labels)) | |
bce_with_logits = nn.BCEWithLogitsLoss() | |
print(bce_with_logits(data, labels)) | |
bce = nn.BCELoss() | |
sigmoid = nn.Sigmoid() | |
print(bce(sigmoid(data), labels)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment