当前位置:网站首页>小记录: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 多平台发布
边栏推荐
猜你喜欢

Advanced Feature Selection Techniques in Linear Models - Based on R

scikit-learn机器学习 读书笔记(一)

Qiskit学习笔记(三)

pytorch框架学习(3)torch.nn.functional模块和nn.Module模块

【格式转换】将JPEG图片批量处理为jpg格式

Interface documentation evolution illustration, some ancient interface documentation tools, you may not have used it

Matlab simulation of multi-factor house price prediction based on BP neural network

summer preschool assignments

【写下自用】每次都忘记如何train?记录如何训练自己的yolov5

An article to master the entire JVM, JVM ultra-detailed analysis!!!
随机推荐
Transforming into a product, is it reliable to take the NPDP test?
I have a dream for Career .
MySql之json_extract函数处理json字段
25张炫酷交互图表,一文入门Plotly
An article to master the entire JVM, JVM ultra-detailed analysis!!!
SQL database field to append to main table
MongoDB 基础了解(一)
8.STM32F407之HAL库——PWM笔记
基于Qiskit——《量子计算编程实战》读书笔记(五)
Thread.sleep, Thread.yield role explanation
`id` bigint(20) unsigned NOT NULL COMMENT 'Database primary key',
Rpc interface stress test
How does flinksql write that the value of redis has only the last field?
ThreadPoolExecutor线程池原理
summer preschool assignments
图纸怎么折?(A0,A1,A2,A3の图纸如何折成A4大小)
Tkinter 入门之旅
strongest brain (1)
Pony语言学习(七)——表达式(Expressions)语法(单篇向)
Jenkins 如何玩转接口自动化测试?