当前位置:网站首页>小记录:Pytorch做深度学习必要加载的包
小记录:Pytorch做深度学习必要加载的包
2022-08-10 05:30:00 【公众号学一点会一点】

根据深度学习模型训练的五个阶段,记录下每个阶段需要加载的包,方便后续总结。
1. 数据
如果不包括数据预处理阶段,只包括数据加载的话,主要用到的就是Dataset和DataLoader,那么就需要导入:
import torch.utils.data as Data
如果需要进行预处理的话,比如标准化这些的话,就还需要导入transform:
import torchvision.transforms as transforms
2. 模型
模型的话主要就是指模型的定义,因为我们的模型类都是继承于torch.nn.Module类,所以需要导入torch.nn:
import torch
import torch.nn as nn
3. 损失函数
Pytorch中的损失函数都是在torch.nn模块下的,所以导入torch.nn即可:
import torch
import torch.nn as nn
4. 优化器
所有的优化器都在torch.optim模块下:
import torch.optim as optim
5. 迭代训练
迭代训练一般就是for循环,有时候为了可视化,需要展示进度条,所以需要tqdm包:
from tqdm import tqdm
其他
在真正进行模型训练的时候,下面一些包也少不了:
import math
import numpy as np
import pandas as pd
import glob
import os
import matplotlib.pyplot as plt

本文由 mdnice 多平台发布
边栏推荐
- R中设置图形参数--函数par()详解
- 再肝3天,整理了90个 NumPy 例子,不能不收藏!
- Concurrency tool class - introduction and use of CountDownLatch, CyclicBarrier, Semaphore, Exchanger
- 树莓派入门(4)LED闪烁&呼吸灯
- Qiskit学习笔记(三)
- Error when installing oracle rac 11g and executing root.sh
- CSDN Markdown 之我见代码块 | CSDN编辑器测评
- PyTorch 入门之旅
- kaggle小白必看:小白常见的2个错误解决方案
- awk of the Three Musketeers of Shell Programming
猜你喜欢

手把手带你写嵌入式物联网的第一个项目

awk of the Three Musketeers of Shell Programming

How to simulate the background API call scene, very detailed!

基于Qiskit——《量子计算编程实战》读书笔记(一)

Talk about API Management - Open Source Edition to SaaS Edition

Order table delete, insert and search operations

如何模拟后台API调用场景,很细!

接口文档进化图鉴,有些古早接口文档工具,你可能都没用过

【Pei Shu Theorem】CF1055C Lucky Days

Arduino框架下合宙ESP32C3 +1.8“tft 网络时钟
随机推荐
Thread.sleep, Thread.yield role explanation
pytorch框架学习(9)torchvision.transform
How to get the last day of a month
pytorch learning
25张炫酷交互图表,一文入门Plotly
我用这一招让团队的开发效率提升了 100%!
openGauss源码,在window系统用VSCode维护吗?
虚拟土地价格暴跌85% 房地产泡沫破裂?依托炒作的暴富游戏需谨慎参与
pytorch 学习
接口文档进化图鉴,有些古早接口文档工具,你可能都没用过
几种绘制时间线图的方法
Stacks and Queues | Implementing Queues with Stacks | Implementing Stacks with Queues | Basic Theory and Code Principles
FPGA engineer interview questions collection 21~30
EasyGBS connects to mysql database and prompts "can't connect to mysql server", how to solve it?
Order table delete, insert and search operations
FPGA engineer interview questions collection 11~20
pytorch框架学习(6)训练一个简单的自己的CNN (三)细节篇
WSTP初体验
反转链表中的第m至第n个节点---leetcode
Flutter development: error The following assertion was thrown resolving an image codec: Solution for Unable to...