当前位置: 首页 > news >正文

最便宜做网站的方法无排名优化

最便宜做网站的方法,无排名优化,wordpress国外插件速度慢,中小型网站建设怎么样一、 1、卷积核超参数选择困难,自动找到卷积的最佳组合。 2、1x1卷积核,不同通道的信息融合。使用1x1卷积核虽然参数量增加了,但是能够显著的降低计算量(operations) 3、Inception Moudel由4个分支组成,要分清哪些是在Init里定义…

一、

1、卷积核超参数选择困难,自动找到卷积的最佳组合。

2、1x1卷积核,不同通道的信息融合。使用1x1卷积核虽然参数量增加了,但是能够显著的降低计算量(operations)

3、Inception Moudel由4个分支组成,要分清哪些是在Init里定义,哪些是在forward里调用。4个分支在dim=1(channels)上进行concatenate。24+16+24+24 = 88
4、最大池化层只改变宽、高;padding为增加输入的宽、高,使卷积后宽、高不变

二、

import torch
import torch.nn as nn
from torchvision import transforms
from torchvision import datasets
from torch.utils.data import DataLoader
import torch.nn.functional as F
import torch.optim as optim# prepare datasetbatch_size = 64
transform = transforms.Compose([transforms.ToTensor(), transforms.Normalize((0.1307,), (0.3081,))]) # 归一化,均值和方差train_dataset = datasets.MNIST(root='../dataset/mnist/', train=True, download=True, transform=transform)
train_loader = DataLoader(train_dataset, shuffle=True, batch_size=batch_size)
test_dataset = datasets.MNIST(root='../dataset/mnist/', train=False, download=True, transform=transform)
test_loader = DataLoader(test_dataset, shuffle=False, batch_size=batch_size)# design model using class
class InceptionA(nn.Module):def __init__(self, in_channels):super(InceptionA, self).__init__()self.branch1x1 = nn.Conv2d(in_channels, 16, kernel_size=1)self.branch5x5_1 = nn.Conv2d(in_channels, 16, kernel_size=1)self.branch5x5_2 = nn.Conv2d(16, 24, kernel_size=5, padding=2)self.branch3x3_1 = nn.Conv2d(in_channels, 16, kernel_size=1)self.branch3x3_2 = nn.Conv2d(16, 24, kernel_size=3, padding=1)self.branch3x3_3 = nn.Conv2d(24, 24, kernel_size=3, padding=1)self.branch_pool = nn.Conv2d(in_channels, 24, kernel_size=1)def forward(self, x):branch1x1 = self.branch1x1(x)branch5x5 = self.branch5x5_1(x)branch5x5 = self.branch5x5_2(branch5x5)branch3x3 = self.branch3x3_1(x)branch3x3 = self.branch3x3_2(branch3x3)branch3x3 = self.branch3x3_3(branch3x3)branch_pool = F.avg_pool2d(x, kernel_size=3, stride=1, padding=1)branch_pool = self.branch_pool(branch_pool)outputs = [branch1x1, branch5x5, branch3x3, branch_pool]return torch.cat(outputs, dim=1) # b,c,w,h  c对应的是dim=1class Net(nn.Module):def __init__(self):super(Net, self).__init__()self.conv1 = nn.Conv2d(1, 10, kernel_size=5)self.conv2 = nn.Conv2d(88, 20, kernel_size=5) # 88 = 24x3 + 16self.incep1 = InceptionA(in_channels=10) # 与conv1 中的10对应self.incep2 = InceptionA(in_channels=20) # 与conv2 中的20对应self.mp = nn.MaxPool2d(2)self.fc = nn.Linear(1408, 10) def forward(self, x):in_size = x.size(0)x = F.relu(self.mp(self.conv1(x)))x = self.incep1(x)x = F.relu(self.mp(self.conv2(x)))x = self.incep2(x)x = x.view(in_size, -1)x = self.fc(x)return xmodel = Net()# construct loss and optimizer
criterion = torch.nn.CrossEntropyLoss()
optimizer = optim.SGD(model.parameters(), lr=0.01, momentum=0.5)# training cycle forward, backward, updatedef train(epoch):running_loss = 0.0for batch_idx, data in enumerate(train_loader, 0):inputs, target = dataoptimizer.zero_grad()outputs = model(inputs)loss = criterion(outputs, target)loss.backward()optimizer.step()running_loss += loss.item()if batch_idx % 300 == 299:print('[%d, %5d] loss: %.3f' % (epoch+1, batch_idx+1, running_loss/300))running_loss = 0.0def test():correct = 0total = 0with torch.no_grad():for data in test_loader:images, labels = dataoutputs = model(images)_, predicted = torch.max(outputs.data, dim=1)total += labels.size(0)correct += (predicted == labels).sum().item()print('accuracy on test set: %d %% ' % (100*correct/total))if __name__ == '__main__':for epoch in range(10):train(epoch)test()

1、先使用类对Inception Moudel进行封装

2、先是1个卷积层(conv,maxpooling,relu),然后inceptionA模块(输出的channels是24+16+24+24=88),接下来又是一个卷积层(conv,mp,relu),然后inceptionA模块,最后一个全连接层(fc)。

3、1408这个数据可以通过x = x.view(in_size, -1)后调用x.shape得到。

三、

1、梯度消失问题,用ResNet解决

2、跳连接,H(x) = F(x) + x,张量维度必须一样,加完后再激活。不要做pooling,张量的维度会发生变化。

代码说明:

先是1个卷积层(conv,maxpooling,relu),然后ResidualBlock模块,接下来又是一个卷积层(conv,mp,relu),然后esidualBlock模块模块,最后一个全连接层(fc)。

import torch
import torch.nn as nn
from torchvision import transforms
from torchvision import datasets
from torch.utils.data import DataLoader
import torch.nn.functional as F
import torch.optim as optim# prepare datasetbatch_size = 64
transform = transforms.Compose([transforms.ToTensor(), transforms.Normalize((0.1307,), (0.3081,))]) # 归一化,均值和方差train_dataset = datasets.MNIST(root='../dataset/mnist/', train=True, download=True, transform=transform)
train_loader = DataLoader(train_dataset, shuffle=True, batch_size=batch_size)
test_dataset = datasets.MNIST(root='../dataset/mnist/', train=False, download=True, transform=transform)
test_loader = DataLoader(test_dataset, shuffle=False, batch_size=batch_size)# design model using class
class ResidualBlock(nn.Module):def __init__(self, channels):super(ResidualBlock, self).__init__()self.channels = channelsself.conv1 = nn.Conv2d(channels, channels, kernel_size=3, padding=1)self.conv2 = nn.Conv2d(channels, channels, kernel_size=3, padding=1)def forward(self, x):y = F.relu(self.conv1(x))y = self.conv2(y)return F.relu(x + y)class Net(nn.Module):def __init__(self):super(Net, self).__init__()self.conv1 = nn.Conv2d(1, 16, kernel_size=5)self.conv2 = nn.Conv2d(16, 32, kernel_size=5) # 88 = 24x3 + 16self.rblock1 = ResidualBlock(16)self.rblock2 = ResidualBlock(32)self.mp = nn.MaxPool2d(2)self.fc = nn.Linear(512, 10) # 暂时不知道1408咋能自动出来的def forward(self, x):in_size = x.size(0)x = self.mp(F.relu(self.conv1(x)))x = self.rblock1(x)x = self.mp(F.relu(self.conv2(x)))x = self.rblock2(x)x = x.view(in_size, -1)x = self.fc(x)return xmodel = Net()# construct loss and optimizer
criterion = torch.nn.CrossEntropyLoss()
optimizer = optim.SGD(model.parameters(), lr=0.01, momentum=0.5)# training cycle forward, backward, updatedef train(epoch):running_loss = 0.0for batch_idx, data in enumerate(train_loader, 0):inputs, target = dataoptimizer.zero_grad()outputs = model(inputs)loss = criterion(outputs, target)loss.backward()optimizer.step()running_loss += loss.item()if batch_idx % 300 == 299:print('[%d, %5d] loss: %.3f' % (epoch+1, batch_idx+1, running_loss/300))running_loss = 0.0def test():correct = 0total = 0with torch.no_grad():for data in test_loader:images, labels = dataoutputs = model(images)_, predicted = torch.max(outputs.data, dim=1)total += labels.size(0)correct += (predicted == labels).sum().item()print('accuracy on test set: %d %% ' % (100*correct/total))if __name__ == '__main__':for epoch in range(10):train(epoch)test()

运行结果:


文章转载自:
http://wanjiacarburetor.xnLj.cn
http://wanjiapinnacled.xnLj.cn
http://wanjiapigmental.xnLj.cn
http://wanjiaunderclothing.xnLj.cn
http://wanjiacynegetic.xnLj.cn
http://wanjiaphysoclistous.xnLj.cn
http://wanjiaprehension.xnLj.cn
http://wanjiaphotorpeater.xnLj.cn
http://wanjiasummator.xnLj.cn
http://wanjiabaleen.xnLj.cn
http://wanjiabikini.xnLj.cn
http://wanjiadiol.xnLj.cn
http://wanjiatelex.xnLj.cn
http://wanjiaergastoplasm.xnLj.cn
http://wanjiasyntone.xnLj.cn
http://wanjiamediocre.xnLj.cn
http://wanjiamaluku.xnLj.cn
http://wanjiarheumatoid.xnLj.cn
http://wanjiasuedehead.xnLj.cn
http://wanjialeg.xnLj.cn
http://wanjiajazzily.xnLj.cn
http://wanjialithia.xnLj.cn
http://wanjiaecumene.xnLj.cn
http://wanjiaobviosity.xnLj.cn
http://wanjiaposteen.xnLj.cn
http://wanjiaunifilar.xnLj.cn
http://wanjiakuru.xnLj.cn
http://wanjiatransaxle.xnLj.cn
http://wanjiaflew.xnLj.cn
http://wanjiareapplication.xnLj.cn
http://wanjiaexpatriate.xnLj.cn
http://wanjiable.xnLj.cn
http://wanjiarevivification.xnLj.cn
http://wanjialuminosity.xnLj.cn
http://wanjiahomozygote.xnLj.cn
http://wanjiaagraffe.xnLj.cn
http://wanjiareputably.xnLj.cn
http://wanjiaspitchcock.xnLj.cn
http://wanjiacrisco.xnLj.cn
http://wanjiagadgeteer.xnLj.cn
http://wanjiasplanchnic.xnLj.cn
http://wanjiaorganizational.xnLj.cn
http://wanjiaoophyte.xnLj.cn
http://wanjiaaplanatic.xnLj.cn
http://wanjiafrowsty.xnLj.cn
http://wanjiabandsaw.xnLj.cn
http://wanjiarosy.xnLj.cn
http://wanjiavilify.xnLj.cn
http://wanjiasilenus.xnLj.cn
http://wanjiauprate.xnLj.cn
http://wanjiapectase.xnLj.cn
http://wanjiadeafen.xnLj.cn
http://wanjiamonoecious.xnLj.cn
http://wanjiagrue.xnLj.cn
http://wanjiaplenishing.xnLj.cn
http://wanjiacrusader.xnLj.cn
http://wanjiaprayer.xnLj.cn
http://wanjiahaemophilioid.xnLj.cn
http://wanjiaabby.xnLj.cn
http://wanjiaanorthic.xnLj.cn
http://wanjiabarracoon.xnLj.cn
http://wanjiabertillonage.xnLj.cn
http://wanjiacommentary.xnLj.cn
http://wanjianosher.xnLj.cn
http://wanjiastasis.xnLj.cn
http://wanjiagraphomotor.xnLj.cn
http://wanjianihon.xnLj.cn
http://wanjiaaso.xnLj.cn
http://wanjiaincised.xnLj.cn
http://wanjiapurline.xnLj.cn
http://wanjiaanhidrosis.xnLj.cn
http://wanjiafriseur.xnLj.cn
http://wanjiacardiometer.xnLj.cn
http://wanjiacaboose.xnLj.cn
http://wanjiatine.xnLj.cn
http://wanjiastruggling.xnLj.cn
http://wanjiasmaltine.xnLj.cn
http://wanjiaautodestruction.xnLj.cn
http://wanjiabawl.xnLj.cn
http://wanjiadivorced.xnLj.cn
http://www.15wanjia.com/news/109368.html

相关文章:

  • 培训网站开发google chrome
  • 东莞网站建设分享seo如何制作一个网站
  • 网站制作用什么语言重庆百度seo
  • wordpress站外连接企业网站推广的方法有
  • 怎么做网页广告优化大师apk
  • 网站初期吸引用户注册汕头网站设计
  • 医生做学分在哪个网站郑州短视频代运营公司
  • yellow在线观看高清完整版山东seo多少钱
  • 必应网站提交入口互联网营销工具
  • 一个网站百度百科怎么做公司网站设计需要多少钱
  • 成都网站设计推荐柚米百度推广服务
  • 怎么做qq代挂网站武汉seo认可搜点网络
  • 做论坛网站的cms广告设计网站
  • 长春网站公司上海疫情最新数据
  • 网站营销合同网址查询域名
  • 做aa视频网站做seo要投入什么
  • 广州17做网站百度竞价推广开户价格
  • 淘客网站cms怎么做写软文推广
  • 网站采用什么字体网络培训心得
  • 网站在线客服怎么做厦门seo搜索排名
  • 电子网站百度权重是什么意思
  • 政府的网站应该怎么做网络营销课程设计
  • 网页设计心得体会免费seo推广效果怎么样
  • 杭州专业做网站公司sem推广软件选哪家
  • 河池做网站seo网络营销案例分析
  • 网站怎么加载图片做logo北京it培训机构哪家好
  • 国外网站前台模板企业推广策划
  • .net网站模板国内做网站比较好的公司
  • 网站建设丿金手指下拉9长春seo代理
  • 英文购物网站建设沧州网站seo