minist資料集的獲取方法

2021-08-28 11:20:14 字數 1269 閱讀 5701

第一次開啟這個資料集,也是一臉懵,不過還好,脫坑**如下:

import numpy as np

import os

# 訓練集

with

open

('./minist_data/train-images.idx3-ubyte'

)as f:

loaded = np.fromfile(

file

= f, dtype = np.uint8)

train_data = loaded[16:

].reshape(

(60000

,784))

print

(train_data.shape)

# (60000, 784)

with

open

('./minist_data/train-labels.idx1-ubyte'

)as f:

loaded = np.fromfile(

file

= f, dtype = np.uint8)

train_labels = loaded[8:

]print

(train_labels.shape)

# (60000,)

# 測試集

with

open

('./minist_data/t10k-images.idx3-ubyte'

)as f:

loaded = np.fromfile(

file

=f, dtype=np.uint8)

test_data = loaded[16:

].reshape(

(10000

,784))

print

(test_data.shape)

# (10000, 784)

with

open

('./minist_data/t10k-labels.idx1-ubyte'

)as f:

loaded = np.fromfile(

file

=f, dtype=np.uint8)

test_labels = loaded[8:

].reshape(

(10000))

print

(test_labels.shape)

# (10000,)

可以看到,訓練集有六萬條樣本,784個特徵。測試集一萬條樣本。

獲取minist資料並轉換成lmdb

caffe本身是沒有資料集的,但在data目錄下有獲取資料的一些指令碼。mnist,乙個經典的手寫數字庫,包含60000個訓練樣本和10000個測試樣本,每個樣本為28 28大小的黑白,手寫數字為0 9,因此分為10類。1.獲取資料 sudo sh data mnist get mnist.sh 這...

資料集的獲取

參考 鏈結 1 開啟乙個空白的excel,選中需要填充數字的區域 2 通過鍵盤直接輸入函式 randbetween start,end 後,按ctrl eenter快捷鍵,自動生成 注釋 randbetween函式用於生成某個數與某個數之間的隨機數 例如 我需要1 5000行內 第一列隨機生成 1 ...

RecordSet資料集獲取心得

下午還在幫助乙個朋友寫串列埠程式,其中碰到乙個資料庫操作問題,我使用了乙個adoquery,執行sql返回乙個recordset,我想在乙個combobox控制項中下拉出這個資料集的所有值,開始我寫的 如下 query.sql.text select from gps open if recordc...