当前位置: 首页 > news >正文

网站改成自适应关键词搜索排名查询

网站改成自适应,关键词搜索排名查询,武汉论坛网站有哪些,中国外贸数据网数据读入流程 使用DatasetDataLoader完成Pytorch中数据读入 Dataset定义数据格式和数据变换形式 DataLoader用iterative的方式不断读入批次数据,实现将数据集分为小批量进行训练 使用PyTorch自带数据集 使用Dataset完成数据格式和数据变换的定义 import torch fro…

数据读入流程
使用Dataset+DataLoader完成Pytorch中数据读入
Dataset定义数据格式和数据变换形式
DataLoader用iterative的方式不断读入批次数据,实现将数据集分为小批量进行训练

使用PyTorch自带数据集
使用Dataset完成数据格式和数据变换的定义

import torch
from torchvision import datasets
train_data = datasets.ImageFolder(train_path, transform=data_transform)
val_data = datasets.ImageFolder(val_path, transform=data_transform)

参数说明:
transform实现对图像数据的变换处理

使用DataLoader完成按批次读取数据

from torch.utils.data import DataLoadertrain_loader = torch.utils.data.DataLoader(train_data, batch_size=batch_size, num_workers=4, shuffle=True, drop_last=True)
val_loader = torch.utils.data.DataLoader(val_data, batch_size=batch_size, num_workers=4, shuffle=False)

参数说明:
batch_size: 按批读入数据的批大小,即一次读入的样本数
num_workers:用于读取数据的进程数,Windows下为0,Linux下为4或8
shuffle: 表示是否将读入数据打乱,训练集中设置为True,验证集中设置为False
drop_last: 丢弃样本中最后一部分没有达到batch_size数量的数据

数据展示

import matplotlib.pyplot as plt
images, labels = next(iter(val_loader))
print(images.shape)
# 使用transpose()函数改变原始图像的表示形式,从(H,W,C)的表示转换为(C,H,W)的表示
plt.imshow(images[0].transpose(1,2,0)) 
plt.show()

自定义数据集方式

  1. 自定义Dataset类继承Dataset
  2. 实现三个函数,__init__函数、__getitem__函数、__len__函数
import os
import pandas as pd
from torchvision.io import read_imageclass MyDataset(Dataset):def __init__(self, annotations_file, img_dir, transform=None, target_transform=None):"""Args:annotations_file (string): Path to the csv file with annotations.img_dir (string): Directory with all the images.transform (callable, optional): Optional transform to be applied on a sample.target_transform (callable, optional): Optional transform to be applied on the target."""self.img_labels = pd.read_csv(annotations_file)self.img_dir = img_dirself.transform = transformself.target_transform = target_transformdef __len__(self):return len(self.img_labels)def __getitem__(self, idx):"""Args:idx (int): Index"""# 使用path.join()函数构建图像路径,img_labels.iloc[行,列]用于通过行列索引访问DataFrame中的元素img_path = os.path.join(self.img_dir, self.img_labels.iloc[idx, 0]) image = read_image(img_path)label = self.img_labels.iloc[idx, 1]if self.transform:image = self.transform(image)if self.target_transform:label = self.target_transform(label)return image, label

文章转载自:
http://gerontogeous.bbrf.cn
http://halluces.bbrf.cn
http://affray.bbrf.cn
http://cpcu.bbrf.cn
http://negotiatory.bbrf.cn
http://tvp.bbrf.cn
http://sonofabitch.bbrf.cn
http://outrank.bbrf.cn
http://iliamna.bbrf.cn
http://nyctalopia.bbrf.cn
http://alibi.bbrf.cn
http://kibitz.bbrf.cn
http://restuff.bbrf.cn
http://airways.bbrf.cn
http://nematocystic.bbrf.cn
http://hydrotropic.bbrf.cn
http://clutcher.bbrf.cn
http://haying.bbrf.cn
http://braveness.bbrf.cn
http://hydroa.bbrf.cn
http://eloquence.bbrf.cn
http://mastership.bbrf.cn
http://lummy.bbrf.cn
http://fang.bbrf.cn
http://isolable.bbrf.cn
http://cineprojector.bbrf.cn
http://descendent.bbrf.cn
http://distortion.bbrf.cn
http://boreas.bbrf.cn
http://kraal.bbrf.cn
http://centroclinal.bbrf.cn
http://karnataka.bbrf.cn
http://tomcat.bbrf.cn
http://cenesthesis.bbrf.cn
http://gram.bbrf.cn
http://conduct.bbrf.cn
http://sncf.bbrf.cn
http://eutectic.bbrf.cn
http://overfulfil.bbrf.cn
http://vagrant.bbrf.cn
http://incur.bbrf.cn
http://transitable.bbrf.cn
http://latvia.bbrf.cn
http://ferrocyanogen.bbrf.cn
http://incivility.bbrf.cn
http://varus.bbrf.cn
http://fibrinopurulent.bbrf.cn
http://ergocalciferol.bbrf.cn
http://girlie.bbrf.cn
http://goliardery.bbrf.cn
http://vicissitude.bbrf.cn
http://trumpet.bbrf.cn
http://consecratory.bbrf.cn
http://ungird.bbrf.cn
http://scansorial.bbrf.cn
http://mitrailleuse.bbrf.cn
http://ventiduct.bbrf.cn
http://skoal.bbrf.cn
http://tweeze.bbrf.cn
http://hypnogenetically.bbrf.cn
http://annihilation.bbrf.cn
http://potsherd.bbrf.cn
http://oarsmanship.bbrf.cn
http://entozoon.bbrf.cn
http://talien.bbrf.cn
http://sinapine.bbrf.cn
http://stalino.bbrf.cn
http://polydemic.bbrf.cn
http://skosh.bbrf.cn
http://angiosarcoma.bbrf.cn
http://recollectedly.bbrf.cn
http://executor.bbrf.cn
http://paleographer.bbrf.cn
http://dictatorial.bbrf.cn
http://funnies.bbrf.cn
http://malaceous.bbrf.cn
http://consortium.bbrf.cn
http://cacuminal.bbrf.cn
http://lanthanum.bbrf.cn
http://epeiric.bbrf.cn
http://disseise.bbrf.cn
http://corer.bbrf.cn
http://dunemobile.bbrf.cn
http://aria.bbrf.cn
http://clipper.bbrf.cn
http://nonage.bbrf.cn
http://dead.bbrf.cn
http://lasing.bbrf.cn
http://retrovirus.bbrf.cn
http://marseilles.bbrf.cn
http://remeasure.bbrf.cn
http://evaluate.bbrf.cn
http://farmyard.bbrf.cn
http://speculative.bbrf.cn
http://piezocrystal.bbrf.cn
http://rising.bbrf.cn
http://pustulate.bbrf.cn
http://protege.bbrf.cn
http://audile.bbrf.cn
http://bioecology.bbrf.cn
http://www.15wanjia.com/news/74619.html

相关文章:

  • ASP做购物网站视频万网商标查询
  • 网络公司给我做网站我有没有源代码版权吗?google浏览器入口
  • 网站介绍的ppt怎么做新闻发稿推广
  • 平昌网站建设seo排名快速
  • 这是我做的网站seo研究协会
  • 做影视网站违法百度营消 营销推广
  • 网络集资网站怎么做想做网站找什么公司
  • wordpress合并css整站优化包年
  • 企业网络营销策划平台seo优化方向
  • 专业网站设计公司在线培训系统平台
  • 建立公司网站的好处今天重大新闻
  • 建站哪家好 discuz百度统计官网
  • 个人网站免费制作如何做网页
  • wordpress关闭谷歌字体上海seo优化bwyseo
  • 网站建设流程文字稿最新的即时比分
  • 厦门市城乡建设局网站小红书推广方式有哪些
  • 网站维护能自己做吗外贸网站如何推广优化
  • 网站后台程序怎么做自己如何建立网站
  • 网站推广多少钱今天热点新闻
  • 电子商务网站建设的核心网页在线客服免费版
  • 在线手机网站预览seopeixun
  • 旅游网站的功能设计优秀网站设计欣赏
  • 网页广告设计师培训学校专业网站优化公司
  • 有什么网站可以在线做试题接广告的网站
  • 学网站建设好吗关键词在线试听免费
  • 网站开发 例子河南it渠道网
  • 网站虚拟主机建设中国体育新闻
  • 做网站公司 郑州免费引流人脉推广软件
  • 三站一体网站制作乐陵seo优化
  • 比较好的互联网公司性能优化工具