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
from torch import nn | |
import torch | |
import torch.nn.functional as F | |
def probabilistic_l1_loss(mu: torch.Tensor, y_hat: torch.Tensor) -> torch.Tensor: | |
"""Probabilistic L1 loss: Xiangyu He, Jian Cheng, 'Revisiting L1 Loss in Super-Resolution: A Probabilistic View and Beyond'. | |
An attempt at implementing equation (8). | |
Args: |
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 | |
import torch.nn.functional as F | |
class KDLoss(nn.Module): | |
"""Knowledge Distillation loss.""" | |
def __init__(self, dim: int = -1, scale_T: bool = True) -> None: | |
"""Initializer for KDLoss. |
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
from PIL import Image | |
from torch import nn, optim | |
import matplotlib.pyplot as plt | |
def create_frame(lrs, save_path): | |
plt.figure() | |
plt.plot(lrs) | |
plt.xlim(0,200) | |
plt.ylim(0,0.11) |