中文亚洲精品无码_熟女乱子伦免费_人人超碰人人爱国产_亚洲熟妇女综合网

當(dāng)前位置: 首頁 > news >正文

承德做網(wǎng)站優(yōu)化搜狗網(wǎng)址大全

承德做網(wǎng)站優(yōu)化,搜狗網(wǎng)址大全,做bt網(wǎng)站安全不,網(wǎng)站建設(shè) 鄭州💥今天看一下 PyTorch數(shù)據(jù)通常的處理方法~ 一般我們會將dataset用來封裝自己的數(shù)據(jù)集,dataloader用于讀取數(shù)據(jù) Dataset格式說明 💬dataset定義了這個數(shù)據(jù)集的總長度,以及會返回哪些參數(shù),模板: from tor…


💥今天看一下 PyTorch數(shù)據(jù)通常的處理方法~

一般我們會將dataset用來封裝自己的數(shù)據(jù)集,dataloader用于讀取數(shù)據(jù)?

Dataset格式說明?

💬dataset定義了這個數(shù)據(jù)集的總長度,以及會返回哪些參數(shù),模板:

from torch.utils.data import Datasetclass MyDataset(Dataset):def __init__(self, ):# 定義數(shù)據(jù)集包含的數(shù)據(jù)和標(biāo)簽def __len__(self):return len(...)def __getitem__(self, index):# 當(dāng)數(shù)據(jù)集被讀取時,返回一個包含數(shù)據(jù)和標(biāo)簽的元組return self.x_data[index], self.y_data[index]

DataLoader格式說明

my_dataset = DataLoader(mydataset, batch_size=2, shuffle=True,num_workers=4)# num_workers:多進(jìn)程讀取數(shù)據(jù)

導(dǎo)入兩個列表到Dataset

class MyDataset(Dataset):def __init__(self, ):# 定義數(shù)據(jù)集包含的數(shù)據(jù)和標(biāo)簽self.x_data = [i for i in range(10)]self.y_data = [2*i for i in range(10)]def __len__(self):return len(self.x_data)def __getitem__(self, index):# 當(dāng)數(shù)據(jù)集被讀取時,返回一個包含數(shù)據(jù)和標(biāo)簽的元組return self.x_data[index], self.y_data[index]mydataset = MyDataset()
my_dataset = DataLoader(mydataset)for x_i ,y_i in my_dataset:print(x_i,y_i)

💬輸出:

tensor([0]) tensor([0])
tensor([1]) tensor([2])
tensor([2]) tensor([4])
tensor([3]) tensor([6])
tensor([4]) tensor([8])
tensor([5]) tensor([10])
tensor([6]) tensor([12])
tensor([7]) tensor([14])
tensor([8]) tensor([16])
tensor([9]) tensor([18])

💬如果修改batch_size為2,則輸出:

tensor([0, 1]) tensor([0, 2])
tensor([2, 3]) tensor([4, 6])
tensor([4, 5]) tensor([ 8, 10])
tensor([6, 7]) tensor([12, 14])
tensor([8, 9]) tensor([16, 18])
  • 我們可以看出,這是管理每次輸出的批次的
  • 還可以控制用多少個線程來加速讀取數(shù)據(jù)(Num Workers),這參數(shù)和電腦cpu核心數(shù)有關(guān)系,盡量不超過電腦的核心數(shù)

導(dǎo)入Excel數(shù)據(jù)到Dataset中

💥dataset只是一個類,因此數(shù)據(jù)可以從外部導(dǎo)入,我們也可以在dataset中規(guī)定數(shù)據(jù)在返回時進(jìn)行更多的操作,數(shù)據(jù)在返回時也不一定是有兩個。

pip install pandas
pip install openpyxl
class myDataset(Dataset):def __init__(self, data_loc):data = pd.read_ecl(data_loc)self.x1,self.x2,self.x3,self.x4,self.y = data['x1'],data['x2'],data['x3'] ,data['x4'],data['y']def __len__(self):return len(self.x1)def __getitem__(self, idx):return self.x1[idx],self.x2[idx],self.x3[idx],self.x4[idx],self.y[idx]mydataset = myDataset(data_loc='e:\pythonProject Pytorch1\data.xls')
my_dataset = DataLoader(mydataset,batch_size=2)
for x1_i ,x2_i,x3_i,x4_i,y_i in my_dataset:print(x1_i,x2_i,x3_i,x4_i,y_i)

導(dǎo)入圖像數(shù)據(jù)集到Dataset

需要安裝opencv

pip install opencv-python

💯加載官方數(shù)據(jù)集?

有一些數(shù)據(jù)集是PyTorch自帶的,它被保存在TorchVision中,以mnist數(shù)據(jù)集為例進(jìn)行加載:

http://www.risenshineclean.com/news/1686.html

相關(guān)文章:

  • 國內(nèi)產(chǎn)品推廣網(wǎng)站廣州市疫情最新情況
  • 編程和做網(wǎng)站有關(guān)系嗎招商外包
  • 微信api文檔徐州seo代理計費(fèi)
  • 泉州市住房與城鄉(xiāng)建設(shè)局網(wǎng)站seo外鏈?zhǔn)鞘裁匆馑?/a>
  • 手機(jī)網(wǎng)站 pc網(wǎng)站模板百度近日收錄查詢
  • 深圳疫情防控最新通知seo網(wǎng)站關(guān)鍵詞優(yōu)化
  • 怎么判斷網(wǎng)站建設(shè)年齡新媒體運(yùn)營主要做什么
  • 網(wǎng)站寶 西部數(shù)碼網(wǎng)站管理助手廣告最多的網(wǎng)站
  • 淘寶客優(yōu)惠券網(wǎng)站建設(shè)加盟官網(wǎng)怎么做百度推廣運(yùn)營
  • 網(wǎng)站模板可視化編輯百度霸屏培訓(xùn)
  • php企業(yè)網(wǎng)站源代碼如何自己搭建網(wǎng)站
  • 懷化三中網(wǎng)站營銷活動
  • 類似于wordpress搜索引擎seo推廣
  • 3合1網(wǎng)站建設(shè)公司網(wǎng)絡(luò)營銷策劃的具體流程是
  • 網(wǎng)站建設(shè)qianhaiyouseo是什么職位的簡稱
  • web網(wǎng)站開發(fā)歷史河南網(wǎng)站關(guān)鍵詞優(yōu)化代理
  • 工程施工合同協(xié)議書范本什么是seo營銷
  • 網(wǎng)站建設(shè)一意見搜索引擎入口google
  • 阿里云oss做網(wǎng)站白度
  • 百度做公司網(wǎng)站有用嗎淘寶seo搜索引擎原理
  • 有規(guī)范seo 關(guān)鍵詞優(yōu)化
  • 重慶渝中區(qū)企業(yè)網(wǎng)站建設(shè)哪家好百度高級搜索首頁
  • 怎么做淘客手機(jī)網(wǎng)站網(wǎng)站關(guān)鍵詞優(yōu)化方法
  • 可以做任務(wù)的網(wǎng)站有哪些營銷網(wǎng)站都有哪些
  • 湖南建筑公司網(wǎng)站百度廣告客服電話
  • 任何人任意做網(wǎng)站銷售產(chǎn)品違法嗎網(wǎng)站的seo
  • 目前做哪些網(wǎng)站能致富如何做推廣
  • wordpress個性主題電影站的seo
  • 制作靜態(tài)網(wǎng)站模板百度統(tǒng)計數(shù)據(jù)分析
  • 深圳 網(wǎng)站開發(fā)公司陽山網(wǎng)站seo