CNNをトレーニングする必要のあるデータセット(71094列車画像と17000テスト)があります。前処理をして、numpyを使用して行列を作成しようとしましたが、 (71094 * 100 * 100 * 3列車データの場合)[すべての画像はRGB 100×100]です。したがって、私はメモリエラーが発生します。状況にどう対処していますか? これは私のコード..です前処理CNNのnumpyでの画像データセット:メモリエラー
import numpy as np
import cv2
from matplotlib import pyplot as plt
data_dir = './fashion-data/images/'
train_data = './fashion-data/train.txt'
test_data = './fashion-data/test.txt'
f = open(train_data, 'r').read()
ims = f.split('\n')
print len(ims)
train = np.zeros((71094, 100, 100, 3)) #this line causes the error..
for ix in range(train.shape[0]):
i = cv2.imread(data_dir + ims[ix] + '.jpg')
label = ims[ix].split('/')[0]
train[ix, :, :, :] = cv2.resize(i, (100, 100))
print train[0]
train_labels = np.zeros((71094, 1))
for ix in range(train_labels.shape[0]):
l = ims[ix].split('/')[0]
train_labels[ix] = int(l)
print train_labels[0]
np.save('./data/train', train)
np.save('./data/train_labels', train_labels)