This file contains hidden or 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
from collections.abc import Collection | |
from torch import nn | |
class WeightedSumCompositionLoss(nn.Module): | |
def __init__(self, loss_funcs: Collection, weights: Collection): | |
super().__init__() | |
self.loss_funcs = loss_funcs | |
self.weights = weights |
This file contains hidden or 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 | |
import torchvision | |
class VGGPerceptualLoss(nn.Module): | |
DEFAULT_FEATURE_LAYERS = [0, 1, 2, 3] | |
IMAGENET_RESIZE = (224, 224) | |
IMAGENET_MEAN = [0.485, 0.456, 0.406] | |
IMAGENET_STD = [0.229, 0.224, 0.225] |