Created
August 27, 2015 11:27
-
-
Save rsnape/bd1f30db4b789a5f7665 to your computer and use it in GitHub Desktop.
Example of how the IncrementalPCA MemoryError failure can occur.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import numpy as np | |
from sklearn.utils import check_array | |
ut = np.memmap('D:\\my_array2.mmap', dtype=np.float16, mode='w+', shape=(140000,3504)) | |
print repr(ut), ut.shape | |
res = check_array(ut) | |
print 'Memory check passed',repr(res),res.shape #This will print the same contents and shape as above | |
res = check_array(ut, dtype=np.float) # This is the actual line used in IncrementalPCA | |
# https://github.com/scikit-learn/scikit-learn/blob/0.16.X/sklearn/decomposition/incremental_pca.py#L165 | |
print 'Never reaches here' # You'll get a memory error - this will never print |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Amazing spot!!! Thanks! It seems for the time being as I might use np.float64 on a machine with a larger RAM.