1. 程式人生 > >tensorflow:簡單的讀取CSV檔案,並實現分批操作

tensorflow:簡單的讀取CSV檔案,並實現分批操作

import numpy as np
from tensorflow.contrib.learn.python.learn.datasets import base

filename = "SiteBUDP_test_label.csv"

test = base.load_csv_without_header(filename=filename,target_dtype=np.int,features_dtype=np.int)

print(test.data.shape,test.target.shape)

test_data=test.data
test_target=test.target

rand_inx=np.random.choice(len(test_data),size=500)

rand_x = test_data[rand_inx]
rand_y = test_target[rand_inx]

print(rand_x.shape,rand_y.shape)

資料集為CSV檔案,有10000行,10列

程式輸入如下: