我尝试运行语言建模程序。当我在文档中使用包含 15000 个句子的数据序列时,程序运行正常。但是,当我尝试使用更大的数据(大 10 倍)更改数据时,遇到如下错误:
Traceback (most recent call last):
File "<ipython-input-2-aa5ef9098286>", line 1, in <module>
runfile('C:/Users/cerdas/Documents/Bil/Lat/lstm-plato-lm/platolm.py', wdir='C:/Users/cerdas/Documents/Bil/Lat/lstm-plato-lm')
File "C:\Users\cerdas\Anaconda3\lib\site-packages\spyder\utils\site\sitecustomize.py", line 705, in runfile
execfile(filename, namespace)
File "C:\Users\cerdas\Anaconda3\lib\site-packages\spyder\utils\site\sitecustomize.py", line 102, in execfile
exec(compile(f.read(), filename, 'exec'), namespace)
File "C:/Users/cerdas/Documents/Bil/Lat/lstm-plato-lm/platolm.py", line 35, in <module>
y = to_categorical(y, num_classes=vocab_size)
File "C:\Users\cerdas\Anaconda3\lib\site-packages\keras\utils\np_utils.py", line 30, in to_categorical
categorical = np.zeros((n, num_classes), dtype=np.float32)
MemoryError
这是可疑的错误代码行:
model.compile(loss='categorical_crossentropy', optimizer='adam', metrics=['accuracy'])
还有 np.utils
categorical = np.zeros((n, num_classes), dtype=np.float64)
我试图搜索类似问题的解决方案,我发现我必须更改categorical_crossentropy为sparse_categorical_crossentropy. 我已经这样做了,但同样的回溯仍然是错误的。
谢谢
小怪兽爱吃肉
一只萌萌小番薯
相关分类