https://gist.github.com/shihyu/a56fb45dfb7781a48bcb7199cad25a0f
下面写成一行
train_data = np.stack([np.array(Image.open("./data/56_imitate_train_set/" +
'{0:05}'.format(int(row[0])) + ".jpg"))/255.0 for row in
csv.reader(traincsv)])
会出现 MemoryError, 下面错误讯息
Traceback (most recent call last):
File "test.py", line 22, in <module>
train_data = np.stack([np.array(Image.open("./data/56_imitate_train_set/"
+ '{0:05}'.format(int(row[0])) + ".jpg"))/255.0 for row in
csv.reader(traincsv)])
File
"/home/shihyu/anaconda3/lib/python3.6/site-packages/numpy/core/shape_base.py",
line 360, in stack
return _nx.concatenate(expanded_arrays, axis=axis, out=out)
MemoryError
但是把一行下面拆开来写是ok
for row in csv.reader(traincsv):
tmp = [np.array(Image.open("./data/56_imitate_train_set/" +
'{0:05}'.format(int(row[0])) + ".jpg"))/255.0]
train_data = np.stack(tmp)
请问这是什么原因?
谢谢