多尺度残差超分辨率

from torch import nn
import torch
import os
os.environ['CUDA_VISIBLE_DEVICES']='1'

class CharbonnierLoss(nn.Module):
    """L1 Charbonnierloss."""
    def __init__(self):
        super(CharbonnierLoss, self).__init__()
        self.eps = 1e-6

    def forward(self, X, Y):
        diff = torch.add(X, -Y)
        error = torch.sqrt(diff * diff + self.eps)
        # print(error)
        loss = torch.sum(error)
        return loss
class Conv_ReLU_Block(nn.Module):
    def __init__(self,in_channels=64,out_channels=64,kernel_size=3,dilation=1):
        super(Conv_ReLU_Block, self).__init__()
        self.conv = nn.Conv2d(in_channels=in_channels, out_channels=out_channels, kernel_size=kernel_size, stride=1, padding=(kernel_size+(dilation-1)*(kernel_size-1))//2, bias=False,dilation=dilation)
        self.relu = nn.ReLU(inplace=False)
  

猜你喜欢

转载自blog.csdn.net/qq_40107571/article/details/126954288