当前位置:网站首页>神经网络与深度学习-3- 机器学习简单示例-PyTorch
神经网络与深度学习-3- 机器学习简单示例-PyTorch
2022-06-25 06:40:00 【明朝百晓生】
参考文档
比刷剧还爽!【128集Pytorch源码底层讲解】圈内顶级AI大佬128集源码底层讲解,手把手教你项目实战!——(人工智能、深度学习、机器视觉、AI)_哔哩哔哩_bilibili
【PyTorch实战】强推!2022年B站最好最全的PyTorch实战课程,同济大佬带你入门到实战!(附源码)-人工智能/PyTorch实战/深度学习_哔哩哔哩_bilibili
目录
1: 机器学习分类
2: 评价指标
3: 深度学习主流框架
4: GPU 和 CPU 运行区别
5: 自动求梯度
一 机器学习算法分类
二 评价指标
真正例(TP, True Positive)
假负例 (FN, False Negative)
假正例 (FP, False Positive)
真负例(TN, True Negative)
可以用混淆矩阵(Confusion Matrix)表示
根据上面定义,可以进一步定义查准率,查全率,和F
2.1 查准率(Precision)
2.2 召回率,查全率
2.3 F值,紧缺率和召回率平均值
三 深度学习主流框架
比刷剧还爽!【128集Pytorch源码底层讲解】圈内顶级AI大佬128集源码底层讲解,手把手教你项目实战!——(人工智能、深度学习、机器视觉、AI)_哔哩哔哩_bilibili
四 GPU 和 CPU
# -*- coding: utf-8 -*-
"""
Created on Tue Jun 21 09:45:05 2022
@author: chengxf2
"""
# -*- coding: utf-8 -*-
"""
Created on Mon Jun 20 21:35:56 2022
@author: cxf
"""
import torch
import time
def test_gpu(k = 20):
use_gpu = torch.cuda.is_available()
print(use_gpu)
device = torch.device('cuda')
a = torch.randn(10000,1000)
b = torch.randn(1000,500)
print("\n ---calc by gpu ---")
t0= time.time()
a = a.to(device)
b = b.to(device)
for i in range(k):
c = torch.matmul(a,b)
t1 = time.time()
interval =t1-t0
print('\n device: ', a.device, '\t time: %9.6f'%interval)
def test_cpu(k = 20):
a = torch.randn(10000,1000)
b = torch.randn(1000,500)
print("\n ---calc by cpu ---")
t0= time.time()
for i in range(k):
c = torch.matmul(a,b)
t1 = time.time()
interval =t1-t0
print('\n device: ', a.device, '\t time: %9.6f'%interval)
if __name__ == "__main__":
test_gpu()
#test_cpu()
五 pytorch 自动求导
python 里面求梯度一般都是自己实现
pytorch 里面有autograd 自动实现求梯度
# -*- coding: utf-8 -*-
"""
Created on Tue Jun 21 21:08:21 2022
@author: cxf
"""
import torch
from torch import autograd
def bp():
x = torch.tensor(0.7)
a = torch.tensor(1.0, requires_grad=True)
b = torch.tensor(2.0, requires_grad=True)
c = torch.tensor(3.0, requires_grad= True)
y = a**2*x+b*x+c
print("\n grad ",a.grad, b.grad, c.grad)
grads = autograd.grad(y, [a,b,c])
print("\n after grad ",grads[0], grads[1], grads[1])
if __name__ =="__main__":
bp()
常用的库
边栏推荐
- 双三次差值bicubic
- Sichuan Tuwei ca-is3105w fully integrated DC-DC converter
- 一“石”二“鸟”,PCA有效改善机载LiDAR林下地面点部分缺失的困局
- STL tutorial 4- input / output stream and object serialization
- Find out what informatization is, and let enterprises embark on the right path of transformation and upgrading
- AttributeError: ‘Upsample‘ object has no attribute ‘recompute_ scale_ factor‘
- C reads XML on the web
- VOCALOID笔记
- 【批处理DOS-CMD命令-汇总和小结】-CMD窗口的设置与操作命令(cd、title、mode、color、pause、chcp、exit)
- CPDA|数据分析师成长之路如何起步?
猜你喜欢
My debut is finished!
Function template_ Class template
Chuantuwei ca-is3720lw alternative material No. iso7820fdw
Research on 3D model retrieval method based on two channel attention residual network - Zhou Jie - paper notes
Estimation of dense forest volume based on LIDAR point cloud with few ground points
[batch dos-cmd command - summary and summary] - file and directory operation commands (MD, RD, xcopy, dir, CD, set, move, copy, del, type, sort)
OAuth 2.0一键登录那些事
权限、认证系统相关名词概念
Sichuan earth microelectronics ca-is1200 isolated operational amplifier for current detection
Full range of isolator chips with integrated isolated power supply
随机推荐
Modular programming of wireless transmission module nRF905 controlled by single chip microcomputer
Sichuan Tuwei ca-is3105w fully integrated DC-DC converter
VectorDraw Web Library 10.10
JDBC-DAO层实现
[batch dos-cmd command - summary and summary] - commands related to Internet access and network communication (Ping, Telnet, NSLOOKUP, ARP, tracert, ipconfig)
Sichuan earth microelectronics ca-is1200 isolated operational amplifier for current detection
权限、认证系统相关名词概念
Shell tips (134) simple keyboard input recorder
el-input实现尾部加字
Sichuan earth microelectronics 8-channel isolated digital input receiver
Distributed quorum NWR of the alchemy furnace of the Supreme Master
基于地面点稀少的LiDAR点云的茂密森林蓄积量估算
【批处理DOS-CMD命令-汇总和小结】-上网和网络通信相关命令(ping、telnet、nslookup、arp、tracert、ipconfig)
STL教程4-输入输出流和对象序列化
Domestic MCU perfectly replaces STM chip model of Italy France
Mysql database import SQL file display garbled code
Understand the reasons for impedance matching of PCB circuit board 2021-10-07
C reads XML on the web
CPDA | how to start the growth path of data analysts?
(tool class) quickly add time to code in source insight