unet3 动态分辨率支持

x33g5p2x  于2022-01-09 转载在 其他  
字(0.7k)|赞(0)|评价(0)|浏览(220)

网络结构代码:

# -*- coding: utf-8 -*-
import os
import time
import numpy as np
import cv2
import torch
import torch.nn as nn
import torch.nn.functional as torch_f
from torch.nn import init

def weights_init_normal(m):
    classname = m.__class__.__name__
    #print(classname)
    if classname.find('Conv') != -1:
        init.normal_(m.weight.data, 0.0, 0.02)
    elif classname.find('Linear') != -1:
        init.normal_(m.weight.data, 0.0, 0.02)
    elif classname.find('BatchNorm') != -1:
        init.normal_(m.weight.data, 1.0, 0.02)
        init.constant_(m.bias.data, 0.0)

def weights_init_xavier(m):
    classname = m.__class__.__name__
    #print(classname)
    if classname.find('Conv') != -1:
        init.xavier_normal_(m.weight.data, gain=1)
    elif classname.find('Linear') != -1:
        init.xavier_normal_(m.weight.data, gain=1)
    elif classname.find('Ba

相关文章