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

用table做的网站优化模型有哪些

用table做的网站,优化模型有哪些,哪里可以学做网站,网站3d展示怎么做的今天分享的学习内容主要就是神经网络里面的知识啦,用到的框架就是torch 在这里我也是对自己做一个学习记录,如果不符合大家的口味,大家划走就可以啦 可能没有什么文字或者原理上的讲解,基本上都是代码,但是我还是想说…

今天分享的学习内容主要就是神经网络里面的知识啦,用到的框架就是torch

在这里我也是对自己做一个学习记录,如果不符合大家的口味,大家划走就可以啦

可能没有什么文字或者原理上的讲解,基本上都是代码,但是我还是想说,如果基础不是很好,认认真真敲一遍,会有不一样的感受!!

在这里还有一篇相关内容的补充,大家也可以看一看:

由浅入深,走进深度学习(补充篇:神经网络基础)-CSDN博客

由浅入深,走进深度学习(补充篇:神经网络结构层基础)-CSDN博客

主要内容

目录

内容六 卷积原理、卷积层、卷积层处理图片

内容七 最大池化层

内容八 非线性激活

内容九 线性层以及其他层

内容十 实战,搭建一个小型的神经网络


正片开始

内容六 卷积原理、卷积层、卷积层处理图片

import torch
import torch.nn.functional as Finput = torch.tensor([[1, 2, 0, 3, 1],[0, 1, 2, 3, 1],[1, 2, 1, 0, 0],[5, 6, 2, 2, 1],[3, 2, 3, 5, 1]])kernel = torch.tensor([[1, 2, 1],[2, 3, 1],[3, 0, 1]])print(input.shape)
print(kernel.shape)input = torch.reshape(input, (1, 1, 5, 5))
kernel = torch.reshape(kernel, (1, 1, 3, 3))
print(input.shape)
print(input)
print(kernel.shape)
print(kernel)output = F.conv2d(input, kernel, stride = 1)
print(output.shape)
print(output)import torch
import torch.nn.functional as Finput = torch.tensor([[1, 2, 0, 3, 1],[0, 1, 2, 3, 1],[1, 2, 1, 0, 0],[5, 6, 2, 2, 1],[3, 2, 3, 5, 1]])kernel = torch.tensor([[1, 2, 1],[2, 3, 1],[3, 0, 1]])print(input.shape)
print(kernel.shape)input = torch.reshape(input, (1, 1, 5, 5))
kernel = torch.reshape(kernel, (1, 1, 3, 3))
print(input.shape)
print(input)
print(kernel.shape)
print(kernel)output = F.conv2d(input, kernel, stride = 2)
print(output.shape)
print(output)# 步幅、填充原理
# 步幅:卷积核经过输入特征图的采样间隔。设置步幅的目的:希望减小输入参数的数目,减少计算量
# 填充:在输入特征图的每一边添加一定数目的行列。设置填充的目的:希望每个输入方块都能作为卷积窗口的中心,或使得输出的特征图的长、宽 = 输入的特征图的长、宽。
# 一个尺寸 a * a 的特征图,经过 b * b 的卷积层,步幅(stride)= c,填充(padding)= d,若d等于0,也就是不填充,输出的特征图的尺寸 =(a-b)/ c+1;若d不等于0,也就是填充,输出的特征图的尺寸 =(a+2d-b)/ c+1
import torch
import torch.nn.functional as Finput = torch.tensor([[1, 2, 0, 3, 1],[0, 1, 2, 3, 1],[1, 2, 1, 0, 0],[5, 6, 2, 2, 1],[3, 2, 3, 5, 1]])kernel = torch.tensor([[1, 2, 1],[2, 3, 1],[3, 0, 1]])print(input.shape)
print(kernel.shape)input = torch.reshape(input, (1, 1, 5, 5))
kernel = torch.reshape(kernel, (1, 1, 3, 3))
print(input.shape)
print(input)
print(kernel.shape)
print(kernel)output = F.conv2d(input, kernel, stride = 1, padding = 1) # 周围只填充一层
print(output.shape)
print(output)# 内容六 卷积层
# Conv1d代表一维卷积,Conv2d代表二维卷积,Conv3d代表三维卷积
# kernel_size在训练过程中不断调整,定义为3就是3 * 3的卷积核,实际我们在训练神经网络过程中其实就是对kernel_size不断调整import torch
from torch import nn
from torch.nn import Conv2d
from torch.utils.data import DataLoader
import torchvision# dataset = torchvision.datasets.CIFAR10("dataset", train=False, transform=torchvision.transforms.ToTensor(), download=True)
# dataloader = DataLoader(dataset, batch_size = 64)class net(nn.Module):def __init__(self):super(net, self).__init__()self.conv1 = Conv2d(in_channels = 3, out_channels = 6, kernel_size = 3, stride = 1, padding = 0) # 彩色图像输入为3层,我们想让它的输出为6层,选3 * 3 的卷积def forward(self, x):x = self.conv1return xmodel = net()
print(model)# 卷积层处理图片
import torch
from torch import nn
from torch.nn import Conv2d
from torch.utils.data import DataLoader
import torchvisiondataset = torchvision.datasets.CIFAR10("dataset", train=False, transform=torchvision.transforms.ToTensor(), download=True)
dataloader = DataLoader(dataset, batch_size = 64)class net(nn.Module):def __init__(self):super(net, self).__init__()self.conv1 = Conv2d(in_channels = 3, out_channels = 6, kernel_size = 3, stride = 1, padding = 0)def forward(self, x):x = self.conv1(x)return xmodel = net()
for data in dataloader:img, targets = dataoutput = model(img)# print(img.shape)# print(output.shape) # 输入为3通道32×32的64张图片# print(targets.shape) # 输出为6通道30×30的64张图片

内容七 最大池化层

# 最大池化层有时也被称为下采样   dilation为空洞卷积
# Ceil_model为当超出区域时,只取最左上角的值
# 池化使得数据由5 * 5 变为3 * 3,甚至1 * 1的,这样导致计算的参数会大大减小。例如1080P的电影经过池化的转为720P的电影、或360P的电影后,同样的网速下,视频更为不卡
import torch
from torch import nn
from torch.nn import MaxPool2dinput = torch.tensor([[3, 4, 6, 1, 8],[4, 0, 8, 0, 1],[1, 2, 4, 5, 1],[2, 3, 1, 5, 1],[3, 3, 1, 5, 0]], dtype = torch.float32)input = torch.reshape(input, (-1, 1, 5, 5))
print(input.shape)class net(nn.Module):def __init__(self):super(net, self).__init__()self.maxpool = MaxPool2d(kernel_size = 3, ceil_mode = True)def forward(self, x):x = self.maxpool(x)return xmodel = net()
output = model(input)
print(output.shape)
print(output)import torch
import torchvision
from torch import nn
from torch.nn import MaxPool2d
from torch.utils.data import DataLoaderdataset = torchvision.datasets.CIFAR10("dataset", train=False, transform=torchvision.transforms.ToTensor(), download=True)
dataloader = DataLoader(dataset, batch_size = 64)class net(nn.Module):def __init__(self):super(net, self).__init__()self.maxpool = MaxPool2d(kernel_size = 3, ceil_mode = True)def forward(self, x):x = self.maxpool(x)return xmodel = net()
epoch = 0for data in dataloader:img, tagets = data# print('input', img, epoch)output = model(img)# print('output', output, epoch)epoch = epoch + 1

内容八 非线性激活

# inplace为原地替换,若为True,则变量的值被替换。若为False,则会创建一个新变量,将函数处理后的值赋值给新变量,原始变量的值没有修改
import torch
from torch import nn
from torch.nn import ReLUinput = torch.tensor([[1, -2],[-0.7, 3]])input = torch.reshape(input, (-1, 1, 2, 2))
print(input.shape)class net(nn.Module):def __init__(self):super(net, self).__init__()self.relu = ReLU()def forward(self, x):x = self.relu(x)return xmodel = net()
output = model(input)
print(output.shape)
print(output)
print(output[0][0][1][1])import torch
import torchvision
from torch import nn
from torch.nn import ReLU, Sigmoid
from torch.utils.data import DataLoaderdataset = torchvision.datasets.CIFAR10("dataset", train=False, transform=torchvision.transforms.ToTensor(), download=True)
dataloader = DataLoader(dataset, batch_size = 64)class net(nn.Module):def __init__(self):super(net, self).__init__()self.relu = ReLU()self.sigmoid = Sigmoid()def forward(self, x):x1 = self.relu(x)x2 = self.sigmoid(x1)return x2model = net()
epoch = 0for data in dataloader:imgs, targets = dataoutput = model(imgs)# print(output.shape)epoch = epoch + 1    

内容九 线性层以及其他层

# 线性拉平
import torch
import torchvision
from torch import nn
from torch.nn import ReLU, Sigmoid
from torch.utils.data import DataLoaderdataset = torchvision.datasets.CIFAR10("dataset", train=False, transform=torchvision.transforms.ToTensor(), download=True)
dataloader = DataLoader(dataset, batch_size = 64)for data in dataloader:imgs, targets = data# print(imgs.shape)output = torch.reshape(imgs, (1, 1, 1, -1))# print(output.shape)# 线性层
import torch
import torchvision
from torch import nn
from torch.nn import Linear
from torch.utils.data import DataLoaderdataset = torchvision.datasets.CIFAR10("dataset", train=False, transform=torchvision.transforms.ToTensor(), download=True)
dataloader = DataLoader(dataset, batch_size = 64, drop_last=True)
# drop_last=True:如果设置为 True,则当数据集的大小不能被 batch_size 整除时,会丢弃最后一个不足一个批次的数据
# drop_last=False:如果设置为 False(也是默认值),则当数据集的大小不能被 batch_size 整除时,最后一个批次会包含剩下的样本,可能少于 batch_size
class net(nn.Module):def __init__(self):super(net, self).__init__()self.linear = Linear(196608, 10)def forward(self, x):x = self.linear(x)return xmodel = net()
epoch = 0for data in dataloader:imgs, targets = data# print(imgs.shape)imgs_reshape = torch.reshape(imgs, (1, 1, 1, -1)) # 方法一 拉平# print(imgs_reshape.shape)output = model(imgs_reshape)# print(output.shape)# epoch = epoch + 1# 线性层
import torch
import torchvision
from torch import nn
from torch.nn import Linear
from torch.utils.data import DataLoaderdataset = torchvision.datasets.CIFAR10("dataset", train=False, transform=torchvision.transforms.ToTensor(), download=True)
dataloader = DataLoader(dataset, batch_size = 64, drop_last=True)
# drop_last=True:如果设置为 True,则当数据集的大小不能被 batch_size 整除时,会丢弃最后一个不足一个批次的数据
# drop_last=False:如果设置为 False(也是默认值),则当数据集的大小不能被 batch_size 整除时,最后一个批次会包含剩下的样本,可能少于 batch_size
class net(nn.Module):def __init__(self):super(net, self).__init__()self.linear = Linear(196608, 20)def forward(self, x):x = self.linear(x)return xmodel = net()
epoch = 0for data in dataloader:imgs, targets = data# print(imgs.shape)imgs_flatten = torch.flatten(imgs) # 方法二 拉平展为一维# print(imgs_flatten.shape)output = model(imgs_flatten)# print(output.shape)# epoch = epoch + 1

内容十 实战,搭建一个小型的神经网络

# 把网络结构放在Sequential里面,好处就是代码写起来比较简介、易懂
# 可以根据神经网络每层的尺寸,根据下图的公式计算出神经网络中的参数
import torch
import torchvision
from torch import nn
from torch.nn import Linear, Conv2d, MaxPool2d, Flatten
from torch.utils.data import DataLoader# dataset = torchvision.datasets.CIFAR10("dataset", train=False, transform=torchvision.transforms.ToTensor(), download=True)
# dataloader = DataLoader(dataset, batch_size = 64, drop_last=True)class net(nn.Module):def __init__(self):super(net, self).__init__()self.conv1 = Conv2d(in_channels = 3, out_channels = 32, kernel_size = 5, stride = 1, padding = 2)self.maxpool1 = MaxPool2d(kernel_size = 2, ceil_mode = True)self.conv2 = Conv2d(in_channels = 32, out_channels = 32, kernel_size = 5, stride = 1, padding = 2)self.maxpool2 = MaxPool2d(kernel_size = 2, ceil_mode = True)self.conv3 = Conv2d(in_channels = 32, out_channels = 64, kernel_size = 5, stride = 1, padding = 2)self.maxpool3 = MaxPool2d(kernel_size = 2, ceil_mode = True)self.flatten = Flatten()self.linear1 = Linear(1024, 64)self.linear2 = Linear(64, 10)def forward(self, x):x = self.conv1(x)print(x.shape)x = self.maxpool1(x)print(x.shape)x = self.conv2(x)print(x.shape)x = self.maxpool2(x)print(x.shape)x = self.conv3(x)print(x.shape)x = self.maxpool3(x)print(x.shape)x = self.flatten(x)print(x.shape)x = self.linear1(x)print(x.shape)x = self.linear2(x)print(x.shape)return xmodel = net()
print(model)input = torch.ones((64, 3, 32, 32))
output = model(input)
print(output.shape)
# Sequential神经网络
import torch
import torchvision
from torch import nn
from torch.nn import Linear, Conv2d, MaxPool2d, Flatten, Sequential
from torch.utils.data import DataLoaderclass net(nn.Module):def __init__(self):super(net, self).__init__()self.model = Sequential(Conv2d(in_channels = 3, out_channels = 32, kernel_size = 5, stride = 1, padding = 2),MaxPool2d(kernel_size = 2, ceil_mode = True),Conv2d(in_channels = 32, out_channels = 32, kernel_size = 5, stride = 1, padding = 2),MaxPool2d(kernel_size = 2, ceil_mode = True),Conv2d(in_channels = 32, out_channels = 64, kernel_size = 5, stride = 1, padding = 2),MaxPool2d(kernel_size = 2, ceil_mode = True),Flatten(),Linear(1024, 64),Linear(64, 10))def forward(self, x):x = self.model(x)return xmodel = net()
print(model)input = torch.ones((64, 3, 32, 32))
output = model(input)
print(output.shape)

注:上述内容参考b站up主“我是土堆”的视频!!!


文章转载自:
http://transportability.rnds.cn
http://tchotchke.rnds.cn
http://deciding.rnds.cn
http://relating.rnds.cn
http://landed.rnds.cn
http://hypocorism.rnds.cn
http://alvera.rnds.cn
http://whitethorn.rnds.cn
http://reassign.rnds.cn
http://sonagraph.rnds.cn
http://languishing.rnds.cn
http://colleging.rnds.cn
http://eyelike.rnds.cn
http://anticathode.rnds.cn
http://bctv.rnds.cn
http://bubalis.rnds.cn
http://wiping.rnds.cn
http://spitbox.rnds.cn
http://yaourt.rnds.cn
http://autobiography.rnds.cn
http://wenlockian.rnds.cn
http://splendiferous.rnds.cn
http://represent.rnds.cn
http://despairingly.rnds.cn
http://scrannel.rnds.cn
http://pleurodont.rnds.cn
http://disembosom.rnds.cn
http://sulphite.rnds.cn
http://sunsuit.rnds.cn
http://genetics.rnds.cn
http://hypercharge.rnds.cn
http://blowy.rnds.cn
http://textualism.rnds.cn
http://did.rnds.cn
http://overlay.rnds.cn
http://pythias.rnds.cn
http://homochromous.rnds.cn
http://deexcitation.rnds.cn
http://lithonephrotomy.rnds.cn
http://irian.rnds.cn
http://bicommunal.rnds.cn
http://homogenize.rnds.cn
http://lovesick.rnds.cn
http://playfield.rnds.cn
http://mordva.rnds.cn
http://xanthium.rnds.cn
http://mercenarism.rnds.cn
http://flopover.rnds.cn
http://scoreline.rnds.cn
http://amaurosis.rnds.cn
http://aridity.rnds.cn
http://saxonise.rnds.cn
http://bookstall.rnds.cn
http://airship.rnds.cn
http://aberglaube.rnds.cn
http://anise.rnds.cn
http://croppy.rnds.cn
http://sherbet.rnds.cn
http://canicula.rnds.cn
http://sargodha.rnds.cn
http://sorption.rnds.cn
http://alligatorfish.rnds.cn
http://censer.rnds.cn
http://dyeability.rnds.cn
http://recherche.rnds.cn
http://specialism.rnds.cn
http://delouse.rnds.cn
http://virescence.rnds.cn
http://sulfarsphenamine.rnds.cn
http://christianization.rnds.cn
http://pharmacist.rnds.cn
http://rikisha.rnds.cn
http://diaphoneme.rnds.cn
http://bucolically.rnds.cn
http://glutethimide.rnds.cn
http://examiner.rnds.cn
http://ropemanship.rnds.cn
http://hopcalite.rnds.cn
http://obelia.rnds.cn
http://levi.rnds.cn
http://ncsa.rnds.cn
http://instability.rnds.cn
http://homoplastically.rnds.cn
http://godwinian.rnds.cn
http://grisliness.rnds.cn
http://undoing.rnds.cn
http://polycrystalline.rnds.cn
http://megagametophyte.rnds.cn
http://reasonably.rnds.cn
http://bratislava.rnds.cn
http://effloresce.rnds.cn
http://syphilotherapy.rnds.cn
http://kickoff.rnds.cn
http://datacenter.rnds.cn
http://sidonian.rnds.cn
http://straitly.rnds.cn
http://disloyally.rnds.cn
http://bandolero.rnds.cn
http://anecdotist.rnds.cn
http://trough.rnds.cn
http://www.hrbkazy.com/news/75107.html

相关文章:

  • 怎么在搜索引擎里做网站网页搜索引擎优化心得体会
  • 做网站线西安百度竞价开户
  • 中小企业有哪些公司长安网站优化公司
  • 做网站用什么网最好市场营销实务
  • 怎样做 网站的快捷链接沈阳优化网站公司
  • 湖南营销型企业网站开发如何建网站
  • wordpress发送邮件插件网站站长seo推广
  • 微网站如何建立简述seo
  • 使用h5做的学习网站源码百度seo点击器
  • 做影视网站算侵权吗网站制作报价表
  • 网站开发开票编码归属seo前线
  • 长沙响应式网站设计有哪些域名whois查询
  • 中国建设银行网站缴费系统免费网站推广网站在线
  • 武功网站建设百度推广管理
  • 做网站多久能盈利全网营销
  • 泊头公司做网站优化大师tv版
  • seo排名优化培训班seo模拟点击
  • 图书馆网站参考咨询建设seo文章优化技巧
  • flash网站链接怎么做sem推广托管公司
  • 自己做的网站出现乱码付费推广平台有哪些
  • python制作的网站优化方案模板
  • 网站售后服务模板网站源码建站
  • 专业做网站登录淘宝关键词排名查询网站
  • 唐山网站制作软件西安百度seo
  • 华强北做电子网站建设怎样在网上推广
  • 2345浏览器怎么卸载最干净优化疫情防控 这些措施你应该知道
  • 微网站模板 餐饮小说百度风云榜
  • 南京公司网站建设武汉十大技能培训机构
  • 广州公司网站设计制作网络推广有几种方法
  • 卢松松网站做互联网项目怎么推广