#!/usr/bin/env python3
# -*- coding:utf-8 -*-
# @Time : 2020/2/24 下午7:05
# @Author : MJ
import torch as t
from torch import nn
from torch.nn import functional as F
from torch.autograd import Variable
import torch.optim as optim
import torchvision as tv
import torchvision.transforms as transforms
class ResidualBlock(nn.Module):
"""Achieve the children module:Residual Block"""
def __init__(self,inchannel, outchannel, stride=1, shortcut=None):
super(ResidualBlock, self).__init__()
self.left = nn.Sequential(
nn.Conv2d(inchannel,outchannel,3,stride,1,bias=False),
nn.BatchNorm2d(outchannel),
nn.ReLU(inplace=True),
nn.Conv2d(outchannel,outchannel,3,1,1,bias=False),
nn.BatchNorm2d(outchannel))
self.right = shortcut
def forward(self, x):
out = self.left(x)
residual = x if self
Pytorch--实现ResNet -CAFAR10
最新推荐文章于 2023-08-22 17:08:26 发布