当前位置:网站首页>1. Learn the environment installation and basic calculation of paddlepaddle from scratch
1. Learn the environment installation and basic calculation of paddlepaddle from scratch
2022-07-21 20:20:00 【kakaccys】
paddlepaddle It is Baidu's deep learning framework , Now that it is fully localized , Study paddlepaddle It is necessary .
This series is about paddlepaddle Summary in learning , I hope you like it .
paddlepaddle The official website of Flying propeller PaddlePaddle- Open source deep learning platform from industrial practice .
First step , install anaconda, Here we choose Tsinghua source conda, It's easy to find .
# Open the web site https://mirror.tuna.tsinghua.edu.cn/help/anaconda/
# perhaps wget https://mirrors.tuna.tsinghua.edu.cn/anaconda/archive/Anaconda3-2022.05-Linux-x86_64.sh
chmod +x Anaconda3-2022.05-Linux-x86_64.sh
./Anaconda3-2022.05-Linux-x86_64.sh
The second step , install paddlepaddle Environment , Here we use pip
pip install paddlepaddle -i https://mirror.baidu.com/pypi/simple
The third step , see paddle Of version
pip list|grep paddlepaddle #2.3.1
You can see paddlepaddle Automatically installed to 2.3.1 edition
Step four , Turn on paddle One small demo test , as follows :
import paddle
x = paddle.to_tensor(1)
w = paddle.to_tensor(2)
b = paddle.to_tensor(3)
y = w*x+b
print(y)#Tensor(shape=[1], dtype=int64, place=Place(cpu), stop_gradient=True,[5])
Above ,paddle The simple calculation test is successful .
Step five , Try paddle Gradient calculation in , This is still the case , stay paddle We need to add stop_gradient Make it possible to calculate the gradient .
import paddle
x = paddle.to_tensor(1,stop_gradient=False)
w = paddle.to_tensor(2,stop_gradient=False)
b = paddle.to_tensor(3,stop_gradient=False)
y = w*x+b
print(y)#Tensor(shape=[1], dtype=int64, place=Place(cpu), stop_gradient=True,[5])
y.backward()
print(y.grad)#Tensor(shape=[1], dtype=int64, place=Place(cpu), stop_gradient=True,[1])
print(x.grad)#Tensor(shape=[1], dtype=int64, place=Place(cpu), stop_gradient=True,[2])
print(w.grad)#Tensor(shape=[1], dtype=int64, place=Place(cpu), stop_gradient=True,[1])
print(b.grad)#Tensor(shape=[1], dtype=int64, place=Place(cpu), stop_gradient=True,[1])
You can see back propagation , Calculate the gradient , No problem ,paddle In the vector calculation and back-propagation methods and pytorch More similar , It's just torch Is in the torch.tensor, and paddle Is in the to_tensor.
stay paddle You can also simply create vectors in , You can directly python List data conversion , as follows :
import paddle
x = paddle.to_tensor([2,3])
print(x)#Tensor(shape=[2], dtype=int64, place=Place(cpu), stop_gradient=True,[2, 3])
x = paddle.to_tensor([[2,3]])
print(x)#Tensor(shape=[1, 2], dtype=int64, place=Place(cpu), stop_gradient=True,[[2, 3]])
Many times when building models ,tensor The dimension of is very important , So we can pass .shape obtain , Of course, you can also print directly , Now look at paddle The bottom layer is similar numpy Of .
x = paddle.to_tensor([[2,3]])
print(x.shape)#[1,2]
边栏推荐
- 【PCB】基於STM32F103RCT6搖杆-藍牙模塊開發板-畫板筆記整理
- OPT101单片光电二极管和单电源互阻放大器使用说明
- markdown及IDEA快捷键
- 汇编借助于条件转移实现循环判断是否为平方数
- 桶排序,冒泡排序,快速排序
- 1.从零开始学习paddlepaddle之环境安装与基础计算
- MySQL安装失败
- 快捷键、命令
- [record] the operation of optisystem is stuck, and it is unable to click to close, input variable values and other solutions
- Esp8266 firmware download and burning (include at firmware download address + firmware burning precautions)
猜你喜欢
整合ssm框架的項目
NIO三大核心详解
PyTorch基础知识
Exclusive locking of this profile failed. Another running VMware process may be using a profile.
以独占的方式锁定此配置文件失败。另一个正在运行的VMware进程可能正在使用配置文件。
数据库宿舍管理系统
【PCB】电路板绘制笔记之生产文件整理及输出--画板笔记
Initializing libiomp5.dylib, but found libomp.dylib already initialized
mask rcnn 加载权重报错
Data consistency of Nacos registry cluster
随机推荐
Jenkins plug-in development - provide external access interface
ESP8266固件下载及烧录(收录AT固件下载地址+固件烧录注意事项)
Judge whether there are duplicate values in the "string []" array, and use the HashSet feature to check
【记录】Optisystem运行卡死,无法点击关闭、输入变量数值等问题解决方法
Display method of front desk serial number
分布式事务其中的那些坑
汇编语言大作业
Annotation related learning
Object copying tool class (fastjson)
Project of integrating SSM framework
markdown及IDEA快捷键
合泰HT32--4SPI驱动0.96英寸OLED显示实现
Jprofiler安装及使用教程
Address Book Implementation
JFrame需要调整大小才可以显示控件 在JPanel中setBounds()方法不起作用
UNet复现及环境配置(含数据集)
mysql/sql server通过JDBC连接数据库进行增删改查的步骤
Data type map, empty string, empty key value and other judgment methods are the most detailed in the whole network
Onenote插件,云扩容
汇编借助于条件转移实现循环判断是否为平方数