Skip to content

Instantly share code, notes, and snippets.

View mashrurmorshed's full-sized avatar
🎯
Focusing

Mashrur Morshed mashrurmorshed

🎯
Focusing
View GitHub Profile
@mashrurmorshed
mashrurmorshed / prob_L1_loss.py
Created April 3, 2022 19:39
Probabilistic L1 Loss for Super Resolution
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:
@mashrurmorshed
mashrurmorshed / kd_loss.py
Last active February 26, 2022 09:42
Knowledge Distillation Loss
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.
@mashrurmorshed
mashrurmorshed / LR_scheduling.py
Created July 18, 2020 20:27
A learning rate scheduling policy simulation.
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)