Pytorch从入门到精通:二、dataset与datalodar

数据是深度学习的基础,一般来说,数据量越大,训练出来的模型也越强大。如果现在有了一些数据,该怎么把这些数据加到模型中呢?Pytorch中提供了dataset和dataloader,让我们一起来学习一下吧,dataset和dataloader博主将用几个例子来说明,感谢支持!
在这里插入图片描述

文章目录

  • 一、dataset
  • 二、查看dataset
  • 三、os操作读取文件夹下的对象
  • 四、Dataset
    • Dataset实操一
    • Dataset 实操二
    • dataset实操三
  • 五、 datalodar
    • 自定义dataset并用datalodar加载
  • 六、os的一些操作

一、dataset

提供一种方式去获取数据及其label
● 如何获取每一个数据及其label
● 告诉我们有多少数据
查看pytorch是否可用

print(torch.cuda.is_available()) # 查看当前cuda是否可用
True

二、查看dataset

from torch.utils.data import Dataset
help(Dataset) # 用帮助文档查看Dataset

Help on class Dataset in module torch.utils.data.dataset:
class Dataset(typing.Generic)
| Dataset(*args, **kwds)
|
| An abstract class representing a :class:Dataset.
|
| All datasets that represent a map from keys to data samples should subclass
| it. All subclasses should overwrite :meth:__getitem__, supporting fetching a
| data sample for a given key. Subclasses could also optionally overwrite
| :meth:__len__, which is expected to return the size of the dataset by many
| :class:~torch.utils.data.Sampler implementations and the default options
| of :class:~torch.utils.data.DataLoader.
|
| … note::
| :class:~torch.utils.data.DataLoader by default constructs a index
| sampler that yields integral indices. To make it work with a map-style
| dataset with non-integral indices/keys, a custom sampler must be provided.
|
| Method resolution order:
| Dataset
| typing.Generic
| builtins.object
|
| Methods defined here:
|
| add(self, other: ‘Dataset[T_co]’) -> ‘ConcatDataset[T_co]’
|
| getattr(self, attribute_name)
|
| getitem(self, index) -> +T_co
|
| ----------------------------------------------------------------------
| Class methods defined here:
|
| register_datapipe_as_function(function_name, cls_to_register, enable_df_api_tracing=False) from builtins.type
|
| register_function(function_name, function) from builtins.type
|
| ----------------------------------------------------------------------
| Data descriptors defined here:
|
| dict
| dictionary for instance variables (if defined)
|
| weakref
| list of weak references to the object (if defined)
|
| ----------------------------------------------------------------------
| Data and other attributes defined here:
|
| annotations = {‘functions’: typing.Dict[str, typing.Callable]}
|
| orig_bases = (typing.Generic[+T_co],)
|
| parameters = (+T_co,)
|
| functions = {‘concat’: functools.partial(<function Dataset.register_da…
|
| ----------------------------------------------------------------------
| Class methods inherited from typing.Generic:
|
| class_getitem(params) from builtins.type
|
| init_subclass(*args, **kwargs) from builtins.type
| This method is called when a class is subclassed.
|
| The default implementation does nothing. It may be
| overridden to extend subclasses.
|
| ----------------------------------------------------------------------
| Static methods inherited from typing.Generic:
|
| new(cls, *args, **kwds)
| Create and return a new object. See help(type) for accurate signature.

三、os操作读取文件夹下的对象

import os
dir_path = "hymenoptera_data\\hymenoptera_data\\train\\ants"  # 文件夹目录
data_dir = os.listdir(dir_path)  # 获取文件夹目录中的对象
data_dir

[‘0013035.jpg’,
‘1030023514_aad5c608f9.jpg’,
‘1095476100_3906d8afde.jpg’,
‘1099452230_d1949d3250.jpg’,
‘116570827_e9c126745d.jpg’,
‘1225872729_6f0856588f.jpg’,
‘1262877379_64fcada201.jpg’,
‘1269756697_0bce92cdab.jpg’,
‘1286984635_5119e80de1.jpg’,
‘132478121_2a430adea2.jpg’,
‘1360291657_dc248c5eea.jpg’,
‘1368913450_e146e2fb6d.jpg’,
‘1473187633_63ccaacea6.jpg’,
‘148715752_302c84f5a4.jpg’,
‘1489674356_09d48dde0a.jpg’,
‘149244013_c529578289.jpg’,
‘150801003_3390b73135.jpg’,
‘150801171_cd86f17ed8.jpg’,
‘154124431_65460430f2.jpg’,
‘162603798_40b51f1654.jpg’,
‘1660097129_384bf54490.jpg’,
‘167890289_dd5ba923f3.jpg’,
‘1693954099_46d4c20605.jpg’,
‘175998972.jpg’,
‘178538489_bec7649292.jpg’,
‘1804095607_0341701e1c.jpg’,
‘1808777855_2a895621d7.jpg’,
‘188552436_605cc9b36b.jpg’,
‘1917341202_d00a7f9af5.jpg’,
‘1924473702_daa9aacdbe.jpg’,
‘196057951_63bf063b92.jpg’,
‘196757565_326437f5fe.jpg’,
‘201558278_fe4caecc76.jpg’,
‘201790779_527f4c0168.jpg’,
‘2019439677_2db655d361.jpg’,
‘207947948_3ab29d7207.jpg’,
‘20935278_9190345f6b.jpg’,
‘224655713_3956f7d39a.jpg’,
‘2265824718_2c96f485da.jpg’,
‘2265825502_fff99cfd2d.jpg’,
‘226951206_d6bf946504.jpg’,
‘2278278459_6b99605e50.jpg’,
‘2288450226_a6e96e8fdf.jpg’,
‘2288481644_83ff7e4572.jpg’,
‘2292213964_ca51ce4bef.jpg’,
‘24335309_c5ea483bb8.jpg’,
‘245647475_9523dfd13e.jpg’,
‘255434217_1b2b3fe0a4.jpg’,
‘258217966_d9d90d18d3.jpg’,
‘275429470_b2d7d9290b.jpg’,
‘28847243_e79fe052cd.jpg’,
‘318052216_84dff3f98a.jpg’,
‘334167043_cbd1adaeb9.jpg’,
‘339670531_94b75ae47a.jpg’,
‘342438950_a3da61deab.jpg’,
‘36439863_0bec9f554f.jpg’,
‘374435068_7eee412ec4.jpg’,
‘382971067_0bfd33afe0.jpg’,
‘384191229_5779cf591b.jpg’,
‘386190770_672743c9a7.jpg’,
‘392382602_1b7bed32fa.jpg’,
‘403746349_71384f5b58.jpg’,
‘408393566_b5b694119b.jpg’,
‘424119020_6d57481dab.jpg’,
‘424873399_47658a91fb.jpg’,
‘450057712_771b3bfc91.jpg’,
‘45472593_bfd624f8dc.jpg’,
‘459694881_ac657d3187.jpg’,
‘460372577_f2f6a8c9fc.jpg’,
‘460874319_0a45ab4d05.jpg’,
‘466430434_4000737de9.jpg’,
‘470127037_513711fd21.jpg’,
‘474806473_ca6caab245.jpg’,
‘475961153_b8c13fd405.jpg’,
‘484293231_e53cfc0c89.jpg’,
‘49375974_e28ba6f17e.jpg’,
‘506249802_207cd979b4.jpg’,
‘506249836_717b73f540.jpg’,
‘512164029_c0a66b8498.jpg’,
‘512863248_43c8ce579b.jpg’,
‘518773929_734dbc5ff4.jpg’,
‘522163566_fec115ca66.jpg’,
‘522415432_2218f34bf8.jpg’,
‘531979952_bde12b3bc0.jpg’,
‘533848102_70a85ad6dd.jpg’,
‘535522953_308353a07c.jpg’,
‘540889389_48bb588b21.jpg’,
‘541630764_dbd285d63c.jpg’,
‘543417860_b14237f569.jpg’,
‘560966032_988f4d7bc4.jpg’,
‘5650366_e22b7e1065.jpg’,
‘6240329_72c01e663e.jpg’,
‘6240338_93729615ec.jpg’,
‘649026570_e58656104b.jpg’,
‘662541407_ff8db781e7.jpg’,
‘67270775_e9fdf77e9d.jpg’,
‘6743948_2b8c096dda.jpg’,
‘684133190_35b62c0c1d.jpg’,
‘69639610_95e0de17aa.jpg’,
‘707895295_009cf23188.jpg’,
‘7759525_1363d24e88.jpg’,
‘795000156_a9900a4a71.jpg’,
‘822537660_caf4ba5514.jpg’,
‘82852639_52b7f7f5e3.jpg’,
‘841049277_b28e58ad05.jpg’,
‘886401651_f878e888cd.jpg’,
‘892108839_f1aad4ca46.jpg’,
‘938946700_ca1c669085.jpg’,
‘957233405_25c1d1187b.jpg’,
‘9715481_b3cb4114ff.jpg’,
‘998118368_6ac1d91f81.jpg’,
‘ant photos.jpg’,
‘Ant_1.jpg’,
‘army-ants-red-picture.jpg’,
‘formica.jpeg’,
‘hormiga_co_por.jpg’,
‘imageNotFound.gif’,
‘kurokusa.jpg’,
‘MehdiabadiAnt2_600.jpg’,
‘Nepenthes_rafflesiana_ant.jpg’,
‘swiss-army-ant.jpg’,
‘termite-vs-ant.jpg’,
‘trap-jaw-ant-insect-bg.jpg’,
‘VietnameseAntMimicSpider.jpg’]
注意在windows下,路径使用双斜线\

四、Dataset

Dataset实操一

from torch.utils.data import Dataset
import os
from PIL import Imageclass Mydata(Dataset):def __init__(self,root_path,label_path):self.root_path = root_path  # hymenoptera_data/hymenoptera_data/trainself.label_path = label_path  # /antsself.path = os.path.join(self.root_path,self.label_path)  # 从根目录开始的绝对路径self.image_path = os.listdir(self.path) # 从根目录开始绝对路径文件夹下的对象 hymenoptera_data/hymenoptera_data/train/ants下的图片 type--> listdef __getitem__(self, idx):image_name = self.image_path[idx] # 单一的图片名称image_item_path = os.path.join(self.root_path,self.label_path,image_name)img = Image.open(image_item_path)label = self.label_pathreturn img,labeldef __len__(self):return len(self.image_path)ants_root_path = "hymenoptera_data\\hymenoptera_data\\train"
ants_label_path = "ants"
Ants = Mydata(ants_root_path,ants_label_path)
Ants[0][0].show() # 第一个0是索引,拿到第一个图像和标签,第二个0是拿到第一个图像,并显示出来

D:\anaconda\envs\Gpu-Pytorch\lib\site-packages\tqdm\auto.py:21: TqdmWarning: IProgress not found. Please update jupyter and ipywidgets. See https://ipywidgets.readthedocs.io/en/stable/user_install.html
from .autonotebook import tqdm as notebook_tqdm
在这里插入图片描述

bee_label_path = "bees"
Bees = Mydata(bee_root_path,bee_label_path)
Bees[0][0].show()

在这里插入图片描述

# 创建训练集train = Ants + Bees   # 直接将数据集加起来
print("the length of Ants is ",Ants.__len__())
print("the length of Bees is ",Bees.__len__())
print("the length of train is ",train.__len__())
the length of Ants is  124
the length of Bees is  121
the length of train is  245
# 查看是否正确
train[123][0].show() # 应该为蚂蚁
train[124][0].show() # 应该为蜜蜂

在这里插入图片描述
在这里插入图片描述

Dataset 实操二

#!/usr/bin/env python
# -*- coding: UTF-8 -*-
"""
@Project :Pytorch学习 
@File    :task_3.py
@IDE     :PyCharm 
@Author  :咋
@Date    :2023/6/29 14:29 
"""
from torch.utils.data import Dataset
import os
from PIL import Imageclass Mydata(Dataset):def __init__(self,root_path,image_path,label_path):self.root_path = root_pathself.image_path = image_pathself.label_path = label_pathself.A_image_path = os.path.join(self.root_path,self.image_path)self.A_label_path = os.path.join(self.root_path,self.label_path)self.img_item = os.listdir(self.A_image_path)self.label_item = os.listdir(self.A_label_path)def __getitem__(self, idx):img_name = self.img_item[idx]img_path = os.path.join(self.A_image_path, img_name)label_list = [i.split(".")[0] for i in self.label_item if i.count(".") == 1]# print(label_list)if img_name.split(".")[0] in label_list:img = Image.open(img_path)label_path = os.path.join(self.A_label_path,img_name.split(".")[0])label_path += ".txt"file = open(label_path, 'r')label = file.read()file.close()return img,labelelse:print("{0}没有对应的标签".format(img_name))return 0def __len__(self):return len(self.img_item)train_ants_root_path = "练手数据集\\train"
train_ants_image_path = "ants_image"
train_ants_label_path = "ants_label"
Ants = Mydata(train_ants_root_path,train_ants_image_path,train_ants_label_path)
for i in range(Ants.__len__()):try:print(Ants[i][1])except TypeError:print("跳过此张图片!")
# Ants[122][0].show()
# print(Ants[122][1])

ants
ants
ants
ants
ants
ants
ants
ants
ants
ants
ants
ants
ants
ants
ants
ants
ants
ants
ants
ants
ants
ants
ants
ants
ants
ants
ants
ants
ants
ants
ants
ants
ants
ants
ants
ants
ants
ants
ants
ants
ants
ants
ants
ants
ants
ants
ants
ants
ants
ants
ants
ants
ants
ants
ants
ants
ants
ants
ants
ants
ants
ants
ants
ants
ants
ants
ants
ants
ants
ants
ants
ants
ants
ants
ants
ants
ants
ants
ants
ants
ants
ants
ants
ants
ants
ants
ants
ants
ants
ants
ants
ants
ants
ants
ants
ants
ants
ants
ants
ants
ants
ants
ants
ants
ants
ants
ants
ants
ants
ants
ants
ants
ants
ants
formica.jpeg没有对应的标签
跳过此张图片!
ants
imageNotFound.gif没有对应的标签
跳过此张图片!
ants
ants
ants
ants
ants
ants
添加了异常捕获,解决了图片没有对应标签的问题!

dataset实操三

使用torchvision中的数据集创建dataset

#!/usr/bin/env python
# -*- coding: UTF-8 -*-
"""
@Project :Pytorch_learn 
@File    :dataset_3.py
@IDE     :PyCharm 
@Author  :咋
@Date    :2023/7/2 14:58 
"""
import torchvision
from torch.utils.data import DataLoader
from tensorboardX import SummaryWriter
from torchvision import transforms
dataset = torchvision.datasets.MNIST("./Mnist",train=True,download=True,transform=transforms.ToTensor())
dataloader = DataLoader(dataset,batch_size=64,shuffle=False,num_workers=0)
# 使用tensorboard将dataloader展示出来
'''方式一
# write = SummaryWriter("log_2")
# count = 0
# for data in dataloader:
#     image,label = data
#     # print(data[1])
#     # print(image.shape)
#     write.add_images("dataloader",image,count)
#     count += 1
'''# 方式二
write = SummaryWriter("log_3")
for i,data in enumerate(dataloader):image,label = datawrite.add_images("dataloader",image,i)write.close()

在这里插入图片描述
enumerate会将可迭代对象中的内容和其索引一起返回:

例如对于一个seq,得到:
(0, seq[0]), (1, seq[1]), (2, seq[2])

五、 datalodar

为后面的网络提供不同的数据类型

自定义dataset并用datalodar加载

import torch
import torch.nn as nn
import torch.optim as optim
from torchvision import datasets, transforms
from torch.autograd import Variable
from net import Net
import softmax
from torch.utils.data import Dataset
import os
from PIL import Image
import numpy as nptransform_tool = transforms.ToTensor()  # 创建一个transform工具
# # image_tensor = transform_tool(image)
with open("mnist-label.txt", 'r') as f:label_str = f.read().strip()   # 打开文件读入缓存
class Mydata(Dataset):def __init__(self,image_path):self.image_path = image_path# self.label_path = label_path  # /antsself.image = os.listdir(self.image_path) # 从根目录开始绝对路径文件夹下的对象 hymenoptera_data/hymenoptera_data/train/ants下的图片 type--> listdef __getitem__(self, idx):image_name = self.image[idx] # 单一的图片名称image_item_path = os.path.join(self.image_path,image_name)img = Image.open(image_item_path)# transform_tool = transforms.ToTensor()  # 创建一个transform工具img = transform_tool(img)labels_list = [int(label) for label in label_str.split(',')]  # 读取标签,不用每次都打开labels = np.array(labels_list)label = labels[idx]return img,labeldef __len__(self):return len(self.image)
# trainset = Mydata("mnist-dataset")# 设置训练参数
batch_size = 32
epochs = 5
device = torch.device("cuda:0" if torch.cuda.is_available() else "cpu")
# 数据集
# transform = transforms.Compose([transforms.ToTensor(),
#                                 transforms.Normalize((0.5,), (0.5,))])
# trainset =
# trainset = datasets.MNIST('~/.pytorch/MNIST_data/', download=True, train=True, transform=transform)
trainset = Mydata("mnist-dataset")trainloader = torch.utils.data.DataLoader(trainset, batch_size=batch_size, shuffle=False,num_workers=0)
print(len(trainloader))
# 输出提示信息
print("batch_size:", batch_size)
print("data_batches:", len(trainloader))
print("epochs:", epochs)# 神经网络
net = Net().to(device)
# net.load_state_dict(torch.load('./model/model.pth'))# 损失函数和优化器
# 负对数似然损失
criterion = nn.NLLLoss()
optimizer = optim.SGD(net.parameters(), lr=0.0005, momentum=0.9)
total_correct = 0
total_samples = 0
# 训练网络
```python
for epoch in range(epochs):running_loss = 0.0for i, data in enumerate(trainloader):inputs, labels = datainputs, labels = Variable(inputs).to(device), Variable(labels).to(device)# 反向传播优化参数optimizer.zero_grad()outputs = net(inputs)# outputs = int(net(inputs))# print(outputs)labels = labels.long()# print(labels)# print(type(labels))loss = criterion(outputs, labels)loss.backward()optimizer.step()running_loss += loss.item()# 计算每个batch的准确率_, predicted = torch.max(outputs.data, 1)total_samples += labels.size(0)total_correct += (predicted == labels).sum().item()if i % 5 == 0:    # 每轮输出损失值accuracy = 100.0 * total_correct / total_samplesprint('[epoch: %d, batches: %d] loss: %.5f accuracy: %.2f%%' %(epoch + 1, i + 1, running_loss / 2000, accuracy))total_correct = 0total_samples = 0running_loss = 0.0
torch.save(net.state_dict(), 'model.pth')  # 每轮保存模型参数print('Finished Training')

打开文件可以在定义类之前打开,把文件信息读入缓存中,在__getitem__中读取各个标签,不用每次执行__getitem__都打开一次文件。

六、os的一些操作

windows使用两个\\表示路径
import os
dir_path = "/home/aistudio"  # 文件夹目录
data_dir = os.listdir(dir_path)  # 获取文件夹目录中的对象
label_path = "label"
all_path = os.path.join(dir_path,label_path)

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mzph.cn/news/9109.shtml

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

5-linux中的定时任务调度

定时任务调度 crond 任务调度概述基本语法常用选项快速入门应用实例crond 相关指令 at 定时任务基本介绍at 命令格式at 命令选项at 时间的定义其他指令 crond 任务调度 crontab 进行 定时任务调度 概述 任务调度&#xff1a;是指系统在某个时间执行的特定的命令或程序 任务…

360T7路由器进行WiFi无线中继教程

360T7路由器进行WiFi中继教程 1. 概述2. 360T7路由器进行WiFi中继实现教程2.1 登录路由器管理界面2.2 选择上网方式2.3 搜索WiFi2.4 连接WiFi2.5 点击确认2.6 在主页面查看网络 1. 概述 中继路由系统由一组中继路由器组成&#xff0c;为不能交换路由信息的路由域提供中继路由。…

Docker consul的容器服务更新与发现

&#xff08;1&#xff09;什么是服务注册与发现 服务注册与发现是微服务架构中不可或缺的重要组件。起初服务都是单节点的&#xff0c;不保障高可用性&#xff0c;也不考虑服务的压力承载&#xff0c;服务之间调用单纯的通过接口访问。直到后来出现了多个节点的分布式架构&am…

centos 8安装A10显卡驱动-AI人工智能

centos 8安装A10显卡驱动命令:./NVIDIA-Linux-x86_64-535.54.03.run --kernel-source-path/usr/src/kernels/4.18.0-147.el8.x86_64 安装完毕; 测试: 检查驱动版本号: nvidia-smi 验证驱动模块已加载: lsmod | grep nvidia

【腾讯云 Cloud Studio 实战训练营】沉浸式体验编写一个博客系统

文章目录 前言新建工作空间登录(注册)Cloud Studio 账号&#xff1a;进入 Cloud Studio 控制台&#xff1a;配置工作空间参数&#xff1a;确认并创建工作空间&#xff1a;项目搭建 配置nuxt 脚手架运行项目报错信息解决错误脚手架运行预览问题 开启博客代码配置layout首页配置 …

JVM理论(六)执行引擎--垃圾回收

概述 垃圾: 指的是在运行程序中没有任何指针指向的对象垃圾回收目的: 为了及时清理空间使得程序可以正常运行垃圾回收机制: JVM采取的是自动内存管理,即JVM负责对象的创建以及回收,将程序员从繁重的内存管理释放出来,更加专注业务的开发垃圾回收区域: 频繁收集Young区(新生代)…

配置IPv4 over IPv6隧道示例

IPv4 over IPv6隧道&#xff1a; 在IPv4 Internet向IPv6 Internet过渡后期&#xff0c;IPv6网络被大量部署后&#xff0c;而IPv4网络只是散布在世界各地的一些孤岛。利用隧道技术可以在IPv6网络上创建隧道&#xff0c;从而实现IPv4孤岛的互联&#xff0c;IPv4孤岛能通过IPv6公…

MFC CList 类的使用

MFC提供CList 类&#xff1b; 类CList支持可按顺序或按值访问的非唯一对象的有序列表&#xff1b;CList 列表与双链接列表行为相似&#xff1b; 类型POSITION的变量是列表的关键字&#xff1b;可使用POSITION变量作为循环因子来顺序遍历列表&#xff0c;作为书签来保存位置&am…

自动驾驶数据标注有哪些?

自动驾驶汽车&#xff1a;人工智能(AI)的焦点 人工智能驱动汽车解决方案的市场规模预计到 2025年将增长十倍以上&#xff0c;提升车内体验的商机领域以及 AI 模型的无偏见训练数据的重要性。在本篇中&#xff0c;我们将介绍车外体验的关键组成部分&#xff0c;以及自动驾驶数据…

01背包相关题

题解&#xff1a;dp[j]表示目标和为j时的最大组合种数 class Solution { public:int dp[1005];int findTargetSumWays(vector<int>& nums, int target) {int val;int sum0;for(int i0;i<nums.size();i){sumnums[i];}int wsumtarget;if(w%21){return 0;}else{valw…

区间预测 | MATLAB实现QRGRU门控循环单元分位数回归多输入单输出区间预测

区间预测 | MATLAB实现QRGRU门控循环单元分位数回归时间序列区间预测 目录 区间预测 | MATLAB实现QRGRU门控循环单元分位数回归时间序列区间预测效果一览基本介绍模型描述程序设计参考资料 效果一览 基本介绍 MATLAB实现QRGRU门控循环单元分位数回归分位数回归多输入单输出区间…

微服务Day4——Docker

一、什么是Docker 微服务虽然具备各种各样的优势&#xff0c;但服务的拆分通用给部署带来了很大的麻烦。 分布式系统中&#xff0c;依赖的组件非常多&#xff0c;不同组件之间部署时往往会产生一些冲突。在数百上千台服务中重复部署&#xff0c;环境不一定一致&#xff0c;会…

npm 安装报错:源文本中存在无法识别的标记

npm install -g vue/cli 源文本中存在无法识别的标记。 所在位置 行:1 字符: 16 npm install -g <<<< vue/cli CategoryInfo : ParserError: (:) [], ParentContainsErrorRecordException FullyQualifiedErrorId : UnrecognizedToken 解决方…

064、故障处理之OMM_TiDB

oom 内存溢出&#xff0c;内存泄漏&#xff0c;相当于TiDB不能用了 TiDB Server OOM对业务的影响 TiDB Server上的业务SQL会失败业务响应时间升高前端体验变差 诊断方法 客户端应用 ERROR 2013(HY000): Lost connection to MySQL Server during query日志 dmesg -T | gr…

ARM——点灯实验

循环点灯 RCC寄存器使能GPIOE、GPIOF组寄存器 修改GPIOx组寄存器下的值 通过GPIOx_MODER寄存器设置为输出模式通过GPIOx_OTYOER寄存器设置为推挽输出类型通过GPIOx_OSPEEDR寄存器设置为低速输出通过GPIOx_PUPDR寄存器设置为禁止上下拉电阻点灯 通过GPIOx_ODR寄存器设置为高电…

excel中的vlookup如何实现根据多个条件查找?

目录 简述问题公式思路通用公式三条件查找公式实例 简述 Excel 中根据一个条件查找非常方便&#xff0c;Excel 提供了内置函数 VLOOKUP。但是实际中往往有多种情形&#xff0c;需要根据多个条件进行查找操作&#xff0c;目前没有现成的内置函数。 本篇介绍 VLOOKPCHOOSE 组合…

flask路由添加参数

flask路由添加参数 在 Flask 中&#xff0c;可以通过两种方式在路由中添加参数&#xff1a;在路由字符串中直接指定参数&#xff0c;或者通过 request 对象从请求中获取参数。 在路由字符串中指定参数&#xff1a;可以将参数直接包含在路由字符串中。参数可以是字符串、整数、…

Apipost使用教程

Apipost是一款集API调试、生成文档、Mock、测试于一体的协同工具。单个工具可以同时满足接口测试、生成/分享文档、Mock、流程测试等功能&#xff0c;还有超实用的多人多角色间实时协作的功能。将前端、后端、测试三种角色串联起来&#xff0c;从而实现工作流程无缝衔接、提高研…

(三)RabbitMQ七种模式介绍与代码演示

Lison <dreamlison163.com>, v1.0.0, 2023.06.22 七种模式介绍与代码演示 文章目录 七种模式介绍与代码演示四大交换机四种交换机介绍 工作模式简单模式&#xff08;Hello World&#xff09;工作队列模式&#xff08;Work queues&#xff09;订阅模式&#xff08;Publis…

FPGA设计时序分析一、时序路径

目录 一、前言 二、时序路径 2.1 时序路径构成 2.2 时序路径分类 2.3 数据捕获 2.4 Fast corner/Slow corner 2.5 Vivado时序报告 三、参考资料 一、前言 时序路径字面容易简单地理解为时钟路径&#xff0c;事实时钟存在的意义是为了数据的处理、传输&#xff0c;因此严…