当前位置:网站首页>pytorch_ demo1
pytorch_ demo1
2022-07-27 08:11:00 【Zhai [email protected]】
A simple classification model
model.python
import torchvision
import torch
# Prepare the dataset
from torch import nn
from torch.utils.data import DataLoader
# Building neural networks
class Tudui(nn.Module):
def __init__(self):
super(Tudui,self).__init__()
self.model=nn.Sequential(
nn.Conv2d(3,32,5,1,2),
nn.MaxPool2d(2),
nn.Conv2d(32, 32, 5, 1, 2),
nn.MaxPool2d(2),
nn.Conv2d(32, 64, 5, 1, 2),
nn.MaxPool2d(2),
nn.Flatten(),
nn.Linear(64*4*4,64),
nn.Linear(64,10)
)
def forward(self,x):
x=self.model(x)
return x
if __name__ == '__main__':
tudui=Tudui()
input=torch.ones((64,3,32,32))
output=tudui(input)
print(output.shape)
train.python
import torchvision
import torch
# Prepare the dataset
from torch import nn
from torch.utils.data import DataLoader
# Building neural networks
class Tudui(nn.Module):
def __init__(self):
super(Tudui,self).__init__()
self.model=nn.Sequential(
nn.Conv2d(3,32,5,1,2),
nn.MaxPool2d(2),
nn.Conv2d(32, 32, 5, 1, 2),
nn.MaxPool2d(2),
nn.Conv2d(32, 64, 5, 1, 2),
nn.MaxPool2d(2),
nn.Flatten(),
nn.Linear(64*4*4,64),
nn.Linear(64,10)
)
def forward(self,x):
x=self.model(x)
return x
if __name__ == '__main__':
tudui=Tudui()
input=torch.ones((64,3,32,32))
output=tudui(input)
print(output.shape)
function : stay train.py Run... In file
stay terminal Input in :tensorboard --logdir=logs/train_logs( Where does your log exist , Fill in here )
The effect is as shown in the picture :
版权声明
本文为[Zhai [email protected]@]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/208/202207270809169650.html
边栏推荐
- The response of the database interface is very slow
- idea远程调试
- Shenzhi Kalan Temple
- 【Day42 文献精读】A Bayesian Model of Perceived Head-Centered Velocity during Smooth Pursuit Eye Movement
- shell脚本学习day01
- Introduction, installation and use of netdata performance monitoring tool
- Database startup report error_ user_ connect_ times > 0 error
- Solve the problem of slow batch insertion of MySQL JDBC data
- Practical new drug R & D project management platform
- CommonTitleBar hide left right
猜你喜欢

Qt Creator代码风格插件Beautifier

What are the software tuning methods? Let's see what Feiteng technology experts say about dragon lizard technology

C event usage case subscription event+=

Five day travels to Beijing

北京五日游记

Record a PG master-slave setup and data synchronization performance test process

数据提取2

信息化项目风险控制与应用

File name wildcard rules for kettle
![[resolved] SSO forwarding succeeded, and there was an unexpected error (type=internal server error, status=500) caused by parameters in the forwarding URL](/img/05/41f48160fa7895bc9e4f314ec570c5.png)
[resolved] SSO forwarding succeeded, and there was an unexpected error (type=internal server error, status=500) caused by parameters in the forwarding URL
随机推荐
孙子出题难,儿子监考严。老子不会做,还我上学钱
QingChuang technology joined dragon lizard community to build a new ecosystem of intelligent operation and maintenance platform
DEMO:ST05 找文本ID 信息
Development of three database general SQL code based on PG Oracle and MySQL
File name wildcard rules for kettle
数据提取1
2022/7/26 exam summary
Can Linux install sqlserver
shell脚本学习day01
二零二零年终总结
Things come to conform, the future is not welcome, at that time is not miscellaneous, neither love
企业架构驱动的数字化转型!
Netdata 性能监测工具介绍、安装、使用
The dragon lizard exhibition area plays a new trick this time. Let's see whose DNA moved?
IBM3650M4实体机安装VCenter7.0
My senior
How to obtain the cash flow data of advertising services to help analyze the advertising effect?
[day42 literature intensive reading] a Bayesian model of perfect head centered velocity during smooth pursuit eye movement
Demo:pa30 Bank Country Code default CN enhancement
A quick overview of transformer quantitative papers in emnlp 2020