![](https://img-blog.csdnimg.cn/20201014180756738.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
Pytorch模型汇总
AI浩
2022年博客之星Top8,2021年博客之星Top6,博客专家,华为云云享专家,十佳博主,阿里云专家博主,拥有多项发明专利并参与过国家重大专项,拥有丰富的开发经验。注重理论与实践的结合,让AI学起来不再枯燥。如果大家在看文章的时候,发现了文章的错误,烦请指出,我会及时纠正。
展开
-
非常不错的train方法模板
记录一下,非常不错的train模板。通过这个模板可以学到很多。原创 2022-11-22 18:08:38 · 1022 阅读 · 4 评论 -
TokenMix数据增强
代码链接:https://github.com/Sense-X/TokenMix论文链接:https://arxiv.org/abs/2207.08409tokenmix.py调用方式和mixup的使用方式一样原创 2022-11-09 17:23:44 · 831 阅读 · 1 评论 -
SwitchableNorm
SwitchableNorm是将BN、LN、IN结合,赋予权重,让网络自己去学习归一化层应该使用什么方法。新建switchable_norm.py。使用ResNet调用。原创 2022-11-01 09:59:39 · 548 阅读 · 2 评论 -
repvggplus
【代码】repvggplus。原创 2022-08-23 15:22:46 · 251 阅读 · 0 评论 -
repvggplus
【代码】repvggplus。原创 2022-08-23 15:18:35 · 339 阅读 · 0 评论 -
PSPNet
import torchfrom torch import nnfrom torch.nn import functional as Ffrom model import extractorsclass PSPModule(nn.Module): def __init__(self, features, out_features=1024, sizes=(1, 2, 3, 6)): super().__init__() self.stages = []原创 2022-05-27 20:45:42 · 1946 阅读 · 0 评论 -
PSPNet
import torchfrom torch import nnfrom torch.nn import functional as Ffrom model import extractorsclass PSPModule(nn.Module): def __init__(self, features, out_features=1024, sizes=(1, 2, 3, 6)): super().__init__() self.stages = []原创 2022-05-27 20:44:52 · 196 阅读 · 0 评论 -
PSPNet
import torchfrom torch import nnfrom torch.nn import functional as Ffrom model import extractorsclass PSPModule(nn.Module): def __init__(self, features, out_features=1024, sizes=(1, 2, 3, 6)): super().__init__() self.stages = []原创 2022-05-27 20:39:53 · 225 阅读 · 0 评论 -
RepLKNet
replknet.py# Scaling Up Your Kernels to 31x31: Revisiting Large Kernel Design in CNNs (https://arxiv.org/abs/2203.06717)# Github source: https://github.com/DingXiaoH/RepLKNet-pytorch# Licensed under The MIT License [see LICENSE for details]# Based on C原创 2022-05-27 11:13:15 · 2320 阅读 · 0 评论 -
ConvMAE模型源码
vision_transformer.py# Copyright (c) 2022 Alpha-VL# --------------------------------------------------------# References:# timm: https://github.com/rwightman/pytorch-image-models/tree/master/timm# DeiT: https://github.com/facebookresearch/deit# -----原创 2022-05-27 11:10:54 · 2170 阅读 · 0 评论 -
Coordinate_Attention(pytorch)
import torchimport torch.nn as nnimport mathimport torch.nn.functional as Fclass h_sigmoid(nn.Module): def __init__(self, inplace=True): super(h_sigmoid, self).__init__() self.relu = nn.ReLU6(inplace=inplace) def forward(self,原创 2022-05-24 17:20:31 · 1974 阅读 · 0 评论 -
MobileViT
import torchimport torch.nn as nnfrom einops import rearrangedef conv_1x1_bn(inp, oup):return nn.Sequential(nn.Conv2d(inp, oup, 1, 1, 0, bias=False),nn.BatchNorm2d(oup),nn.SiLU())def conv_nxn_bn(inp, oup, kernal_size=3, stride=1):return nn.Sequen原创 2022-04-27 12:43:35 · 318 阅读 · 0 评论 -
pytorch UNet
unet_parts.py""" Parts of the U-Net model """import torchimport torch.nn as nnimport torch.nn.functional as Fclass DoubleConv(nn.Module): """(convolution => [BN] => ReLU) * 2""" def __init__(self, in_channels, out_channels, mid_chann原创 2022-03-04 16:36:42 · 1025 阅读 · 0 评论 -
acgan
import argparseimport osimport numpy as npimport mathimport torchvision.transforms as transformsfrom torchvision.utils import save_imagefrom torch.utils.data import DataLoaderfrom torchvision import datasetsfrom torch.autograd import Variableim原创 2022-03-03 09:27:10 · 283 阅读 · 0 评论 -
ConViT
""" ConViT Model@article{d2021convit, title={ConViT: Improving Vision Transformers with Soft Convolutional Inductive Biases}, author={d'Ascoli, St{\'e}phane and Touvron, Hugo and Leavitt, Matthew and Morcos, Ari and Biroli, Giulio and Sagun, Levent},原创 2022-02-21 10:35:43 · 1615 阅读 · 2 评论 -
Swin Transformer
github地址:https://github.com/rwightman/pytorch-image-models/记录一下模型,方便查阅""" Swin TransformerA PyTorch impl of : `Swin Transformer: Hierarchical Vision Transformer using Shifted Windows` - https://arxiv.org/pdf/2103.14030Code/weights from https://git原创 2022-02-21 10:33:44 · 1423 阅读 · 0 评论 -
pytorch实现vision_transformer_hybrid
github地址:https://github.com/rwightman/pytorch-image-models/记录一下模型,方便查阅""" Hybrid Vision Transformer (ViT) in PyTorchA PyTorch implement of the Hybrid Vision Transformers as described in:'An Image Is Worth 16 x 16 Words: Transformers for Image Recogni原创 2022-02-21 10:14:54 · 1206 阅读 · 1 评论 -
pytorch实现 vision_transformer
github地址:https://github.com/rwightman/pytorch-image-models/记录一下模型,方便查阅""" Vision Transformer (ViT) in PyTorchA PyTorch implement of Vision Transformers as described in:'An Image Is Worth 16 x 16 Words: Transformers for Image Recognition at Scale'原创 2022-02-21 09:57:03 · 1968 阅读 · 0 评论 -
mpvit
# --------------------------------------------------------------------------------# MPViT: Multi-Path Vision Transformer for Dense Prediction# Copyright (c) 2022 Electronics and Telecommunications Research Institute (ETRI).# All Rights Reserved.# Writt原创 2022-02-05 08:35:23 · 567 阅读 · 0 评论 -
convnext
# Copyright (c) Meta Platforms, Inc. and affiliates.# All rights reserved.# This source code is licensed under the license found in the# LICENSE file in the root directory of this source tree.import torchimport torch.nn as nnimport torch.nn.funct原创 2022-01-18 07:05:20 · 1547 阅读 · 0 评论 -
CoAtNet
import torchimport torch.nn as nnfrom einops import rearrangefrom einops.layers.torch import Rearrangedef conv_3x3_bn(inp, oup, image_size, downsample=False): stride = 1 if downsample == False else 2 return nn.Sequential( nn.Conv2d(i原创 2021-12-10 17:24:38 · 842 阅读 · 0 评论 -
MobileNetXt
import torchimport torch.nn as nnimport torchvisionfrom functools import reducedef Conv3x3BN(in_channels,out_channels,stride=1,groups=1): return nn.Sequential( nn.Conv2d(in_channels=in_channels, out_channels=out_channels, kernel_size=原创 2021-11-29 13:00:00 · 486 阅读 · 0 评论 -
MobileNetV3
import torchimport torch.nn as nnimport torchvisionclass HardSwish(nn.Module): def __init__(self, inplace=True): super(HardSwish, self).__init__() self.relu6 = nn.ReLU6(inplace) def forward(self, x): return x*self.relu6原创 2021-11-29 12:59:29 · 900 阅读 · 0 评论 -
MobileNetV2
import torchimport torch.nn as nnimport torchvisionfrom functools import reducedef Conv3x3BNReLU(in_channels,out_channels,stride,groups): return nn.Sequential( nn.Conv2d(in_channels=in_channels, out_channels=out_channels, kernel_size=原创 2021-11-29 12:58:59 · 345 阅读 · 0 评论 -
MobileNetV1
import torchimport torch.nn as nnimport torchvisiondef BottleneckV1(in_channels, out_channels, stride): return nn.Sequential( nn.Conv2d(in_channels=in_channels,out_channels=in_channels,kernel_size=3,stride=stride,padding=1,groups=in_channels原创 2021-11-29 12:58:29 · 337 阅读 · 0 评论 -
MixNet
import torchimport torch.nn as nnclass HardSwish(nn.Module): def __init__(self, inplace=True): super(HardSwish, self).__init__() self.relu6 = nn.ReLU6(inplace) def forward(self, x): return x*self.relu6(x+3)/6def ConvBN原创 2021-11-29 12:57:56 · 307 阅读 · 0 评论 -
GhostNet
import torchimport torch.nn as nnimport torchvisiondef DW_Conv3x3BNReLU(in_channels,out_channels,stride,groups=1): return nn.Sequential( nn.Conv2d(in_channels=in_channels, out_channels=out_channels, kernel_size=3, stride=stride, padding原创 2021-11-29 12:57:27 · 467 阅读 · 2 评论 -
PolarMask
import torchimport torch.nn as nnimport torchvisiondef Conv3x3ReLU(in_channels,out_channels): return nn.Sequential( nn.Conv2d(in_channels=in_channels,out_channels=out_channels,kernel_size=3,stride=1,padding=1), nn.ReLU6(inplace=True原创 2021-11-29 12:56:53 · 424 阅读 · 0 评论 -
LPN模型
import torchimport torch.nn as nnimport torchvisionfrom context_block import ContextBlockclass LBwithGCBlock(nn.Module): expansion = 1 def __init__(self, inplanes, planes, stride=1, downsample=None): super(LBwithGCBlock, self).__init_原创 2021-11-29 12:56:05 · 863 阅读 · 0 评论 -
Hourglass
import torchimport torch.nn as nnimport torchvisiondef ConvBNReLU(in_channels,out_channels,kernel_size,stride,padding=0): return nn.Sequential( nn.Conv2d(in_channels=in_channels,out_channels=out_channels,kernel_size=kernel_size,stride=strid原创 2021-11-29 12:55:31 · 370 阅读 · 0 评论 -
ContextBlock
import torchfrom torch import nnclass ContextBlock(nn.Module): def __init__(self, inplanes, ratio, pooling_type='att', fusion_types=('channel_add', )): super(ContextBlock, s原创 2021-11-29 12:54:58 · 521 阅读 · 0 评论 -
VarGFaceNet
import torchimport torch.nn as nnimport torchvisionclass SqueezeAndExcite(nn.Module): def __init__(self, in_channels, out_channels, divide=4): super(SqueezeAndExcite, self).__init__() mid_channels = in_channels // divide se原创 2021-11-29 12:53:53 · 267 阅读 · 0 评论 -
LFED模型
import torchimport torch.nn as nndef Conv1x1ReLU(in_channels,out_channels): return nn.Sequential( nn.Conv2d(in_channels=in_channels, out_channels=out_channels, kernel_size=1, stride=1), nn.ReLU6(inplace=True) )def C原创 2021-11-29 12:53:26 · 382 阅读 · 0 评论 -
FaceBoxes
import torchimport torch.nn as nnimport torchvisionclass Conv2dCReLU(nn.Module): def __init__(self,in_channels,out_channels,kernel_size,stride,padding): super(Conv2dCReLU, self).__init__() self.conv = nn.Conv2d(in_channels=in_channe原创 2021-11-29 12:52:18 · 249 阅读 · 0 评论 -
ResNeXt
import torchimport torch.nn as nnimport torchvisionclass ResNeXtBlock(nn.Module): def __init__(self,in_places,places, stride=1,downsampling=False, expansion = 2, cardinality=32): super(ResNeXtBlock,self).__init__() self.expansion =原创 2021-11-27 10:55:27 · 1170 阅读 · 0 评论 -
ResNet
import torchimport torch.nn as nnimport torchvisionprint("PyTorch Version: ",torch.__version__)print("Torchvision Version: ",torchvision.__version__)__all__ = ['ResNet50', 'ResNet101','ResNet152']def Conv1(in_planes, places, stride=2): return原创 2021-11-27 10:54:48 · 313 阅读 · 0 评论 -
RepVGG
# !/usr/bin/env python# -- coding: utf-8 --import numpy as npimport torchimport torch.nn as nndef Conv1x1BN(in_channels,out_channels, stride=1, groups=1, bias=False): return nn.Sequential( nn.Conv2d(in_channels=in_channels, out_chan原创 2021-11-27 10:54:16 · 1160 阅读 · 0 评论 -
VGG16
import torchimport torch.nn as nnimport torchvisiondef Conv3x3BNReLU(in_channels,out_channels): return nn.Sequential( nn.Conv2d(in_channels=in_channels,out_channels=out_channels,kernel_size=3,stride=1,padding=1), nn.BatchNorm2d(out_原创 2021-11-27 10:53:29 · 331 阅读 · 0 评论 -
InceptionV3
import torchimport torch.nn as nnimport torchvisiondef ConvBNReLU(in_channels,out_channels,kernel_size,stride=1,padding=0): return nn.Sequential( nn.Conv2d(in_channels=in_channels, out_channels=out_channels, kernel_size=kernel_size, stride=原创 2021-11-27 10:52:39 · 324 阅读 · 0 评论 -
Pytorch实现InceptionV2
import torchimport torch.nn as nnimport torchvisiondef ConvBNReLU(in_channels,out_channels,kernel_size,stride=1,padding=0): return nn.Sequential( nn.Conv2d(in_channels=in_channels, out_channels=out_channels, kernel_size=kernel_size, stride=原创 2021-11-27 10:51:56 · 703 阅读 · 0 评论