モデルをトレーニングしたい独自のデータセットがあります。.pk.gz ファイルを正常に作成しましたが、それらをモデルにインポートする方法がわかりません。
私はWindows 10、python 3.5.2、tensor-flow、tflearn、sublime text 3を使用してコードを記述しています。
pickle ファイルの作成に使用したコード:
from numpy import genfromtxt
import gzip
import _pickle as cPickle
#data = sio.loadmat('C:/DeepLearning_lib/Theano/Data/test_x.mat')
train_set_x = genfromtxt('C:/Users/Jay/Desktop/MachineLearning/dataset/NSL-KDD Processed/Kdd_Train_41.csv', delimiter=',')
train_set_y = genfromtxt('C:/Users/Jay/Desktop/MachineLearning/dataset/NSL-KDD Processed/NSL_TrainLabels_mat4.csv', delimiter=',')
valid_set_x = genfromtxt('C:/Users/Jay/Desktop/MachineLearning/dataset/NSL-KDD Processed/Kdd_Valid_41.csv', delimiter=',')
valid_set_y = genfromtxt('C:/Users/Jay/Desktop/MachineLearning/dataset/NSL-KDD Processed/NSL_ValidLabels_int2.csv', delimiter=',')
test_set_x = genfromtxt('C:/Users/Jay/Desktop/MachineLearning/dataset/NSL-KDD Processed/Kdd_Test_41.csv', delimiter=',')
test_set_y = genfromtxt('C:/Users/Jay/Desktop/MachineLearning/dataset/NSL-KDD Processed/NSL_TestLabels_mat5.csv', delimiter=',')
train_set = test_set_x
train_set_labels= test_set_y
valid_set = valid_set_x
valid_set_labels= valid_set_y
test_set = train_set_x
test_set_labels= train_set_y
f = gzip.open('C:/Users/Jay/Desktop/Data/train_set.pkl.gz','wb')
cPickle.dump(train_set, f, protocol=2)
f.close()
f = gzip.open('C:/Users/Jay/Desktop/Data/train_set_labels.pkl.gz','wb')
cPickle.dump(train_set_labels, f, protocol=2)
f.close()
f = gzip.open('C:/Users/Jay/Desktop/Data/valid_set_labels.pkl.gz','wb')
cPickle.dump(valid_set_labels, f, protocol=2)
f.close()
f = gzip.open('C:/Users/Jay/Desktop/Data/test_set_labels.pkl.gz','wb')
cPickle.dump(test_set_labels, f, protocol=2)
f.close()
f = gzip.open('C:/Users/Jay/Desktop/Data/valid_set.pkl.gz','wb')
cPickle.dump(valid_set, f, protocol=2)
f.close()
f = gzip.open('C:/Users/Jay/Desktop/Data/test_set.pkl.gz','wb')
cPickle.dump(test_set, f, protocol=2)
f.close()
エラー : 'rb' を使用した場合
'OSError: [Errno 9] peek() on write-only GzipFile object'