MCPcopy Create free account
hub / github.com/QWTforGithub/T2LDM / __init__

Method __init__

utils/common.py:459–484  ·  view source on GitHub ↗
(
        self,
        pred="n_pred",
        target="n_target",
        weight=None,
        size_average=None,
        reduce=None,
        reduction="mean",
        label_smoothing=0.0,
        loss_weight=1.0,
        ignore_index=-1,
    )

Source from the content-addressed store, hash-verified

457
458class CrossEntropyLoss(nn.Module):
459 def __init__(
460 self,
461 pred="n_pred",
462 target="n_target",
463 weight=None,
464 size_average=None,
465 reduce=None,
466 reduction="mean",
467 label_smoothing=0.0,
468 loss_weight=1.0,
469 ignore_index=-1,
470 ):
471 super(CrossEntropyLoss, self).__init__()
472
473 weight = torch.tensor(weight).cuda() if weight is not None else None
474 self.loss_weight = loss_weight
475 self.ignore_index = ignore_index
476 self.pred = pred
477 self.target = target
478 self.loss = nn.CrossEntropyLoss(
479 weight=weight,
480 size_average=size_average,
481 reduce=reduce,
482 reduction=reduction,
483 label_smoothing=label_smoothing,
484 )
485
486 def forward(self, pred, target):
487

Callers

nothing calls this directly

Calls 1

__init__Method · 0.45

Tested by

no test coverage detected