Encountered this problem is to initialize a large matrix:
import numpy as np
init_a = np.zeros((10000*10000,4096))
Direct initialization like this prompts a MemoryError.
Looking up the data, it finds that the default dtype=float64
; therefore, after modifying the data type as float16
, the error is avoided. Although the accuracy is lost, the code runs successfully:
init_a = np.zeros((10000*10000,4096),dtype='float16')
If there is a better solution, please advise ~