Exemplo n.º 1
0
    def __init__(self, target):
        super(StyleLossMeanStdSkew, self).__init__()
        self.target_mean = torch.abs(compute_i_th_moment(target, 1))
        self.target_std = torch.abs(compute_i_th_moment(target, 2))
        self.target_skewness = torch.abs(compute_i_th_moment(target, 3))

        self.loss = 0
Exemplo n.º 2
0
    def forward(self, input):
        input_mean = compute_i_th_moment(input, 1)
        input_std = compute_i_th_moment(input, 2)
        input_skewness = compute_i_th_moment(input, 3)
        input_kurtosis = compute_i_th_moment(input, 4)

        # use balancing factor
        mean_balancing_factor = torch.min(
            1 / torch.mean(self.target_mean).to(device),
            torch.tensor(1.).to(device))
        std_balancing_factor = torch.min(
            1 / torch.mean(self.target_std).to(device),
            torch.tensor(1.).to(device))
        skew_balancing_factor = torch.min(
            1 / torch.mean(self.target_skewness).to(device),
            torch.tensor(1.).to(device))
        kurtosis_balancing_factor = torch.min(
            1 / torch.mean(self.target_kurtosis).to(device),
            torch.tensor(1.).to(device))

        self.loss = mean_balancing_factor * F.mse_loss(input_mean.to(device), self.target_mean.to(device))           \
                  + std_balancing_factor * F.mse_loss(input_std.to(device), self.target_std.to(device))              \
                  + skew_balancing_factor * F.mse_loss(input_skewness.to(device), self.target_skewness.to(device))   \
                  + kurtosis_balancing_factor * F.mse_loss(input_kurtosis.to(device), self.target_kurtosis.to(device))

        return input
Exemplo n.º 3
0
    def __init__(self, target):
        super(StyleLossMeanStdSkewKurtosis, self).__init__()
        self.target_mean = compute_i_th_moment(target, 1)
        self.target_std = compute_i_th_moment(target, 2)
        self.target_skewness = compute_i_th_moment(target, 3)
        self.target_kurtosis = compute_i_th_moment(target, 4)

        self.loss = 0
Exemplo n.º 4
0
    def forward(self, input):
        input_mean = torch.abs(compute_i_th_moment(input, 1))
        input_std = torch.abs(compute_i_th_moment(input, 2))

        # use balancing factor
        mean_balancing_factor = torch.min(1 / torch.mean(self.target_mean).to(device), torch.tensor(1.).to(device))
        std_balancing_factor = torch.min(1 / torch.mean(self.target_std).to(device), torch.tensor(1.).to(device))

        self.loss = torch.abs(mean_balancing_factor) * F.mse_loss(input_mean.to(device), self.target_mean.to(device)) \
                  + torch.abs(std_balancing_factor) * F.mse_loss(input_std.to(device), self.target_std.to(device))

        return input
Exemplo n.º 5
0
    def forward(self, input):
        input_mean = compute_i_th_moment(input, 1)

        # use balancing factor
        mean_balancing_factor = torch.min(
            1 / torch.mean(self.target_mean).to(device),
            torch.tensor(1.).to(device))

        self.loss = mean_balancing_factor * F.mse_loss(
            input_mean.to(device), self.target_mean.to(device))

        return input
Exemplo n.º 6
0
    def __init__(self, target):
        super(StyleLossMean, self).__init__()
        self.target_mean = torch.abs(compute_i_th_moment(target, 1))

        self.loss = 0
Exemplo n.º 7
0
    def __init__(self, target):
        super(StyleLossMeanStd, self).__init__()
        self.target_mean = compute_i_th_moment(target, 1)
        self.target_std = compute_i_th_moment(target, 2)

        self.loss = 0