- 博客(7)
- 收藏
- 关注
原创 上采样
import torchimport torch.nn as nna = torch.arange(1,5,dtype=torch.float32).view(1,1,2,2)print(a)b = nn.Upsample(scale_factor=2,mode="nearest")#缩放因子print(b(a))#临近上采样c = nn.Upsample(scale_factor...
2020-01-14 18:04:04 179
原创 通道混洗(Channel shuffle)
import torch#通道混洗(Channel shuffle)#目的:在不增加计算量的情况下,使通道充分融合x = torch.randn(4,6,3,3)y = x.reshape(4,2,3,3,3)print(y.shape)z = y.permute(0,2,1,3,4)print(z.shape)v = z.reshape(4,6,3,3)print(v.shap...
2020-01-11 17:35:44 5102 1
原创 残差网络
import torchimport torch.nn as nn#残差class ResNet(nn.Module): def __init__(self): super(ResNet,self).__init__() self.conv = nn.Conv2d(3,6,3,1,padding=1) def forward(self,x):...
2020-01-11 17:15:21 118
原创 分组卷积(计算量)
import torchimport torch.nn as nn#分组卷积N,C_in,H,W,C_out = 10,4,16,16,4x = torch.randn(N,C_in,H,W)conv = nn.Conv2d(C_in,C_out,3,1,padding=0,bias=False)conv_group = nn.Conv2d(C_in,C_out,3,1,padding...
2020-01-10 13:15:26 1051
原创 对图像进行简单卷积和池化
import torchimport torch.nn as nnfrom PIL import Imageimport numpy as npimg = Image.open("pic1.jpeg")#加载图片img = np.array(img)#转为numpy形式#print(img.shape)img = np.reshape(img,(1,1244,700,3))#转为N...
2020-01-09 17:25:54 336
原创 python生成随机验证码(2)
from PIL import Image,ImageDraw,ImageFont#图片,画画,字体import random随机的字母def randChar():# return random.randint(65,90)#随机整数return chr(random.randint(65,90))#随机字母print(randChar())# 编码表随机颜色def randCo...
2020-01-07 15:17:36 110
原创 python生成随机验证码(OOP)
import randomdef getcode():return chr(random.randint(65,90))def getforeground():return (random.randint(60,120),random.randint(60,120),random.randint(60,120))def getbackground():return (random.ra...
2020-01-07 15:16:05 128
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人