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 ~
Read More:
- The sparse matrix of R language is too large to be used as.matrix
- Python error memoryerror
- Memory error in Python numpy matrix
- python MemoryError: Unable to allocate 165. MiB for an array with shape
- Python reports oserror: initializing from file failed
- [Python error] memoryerror
- The solution of pychar’s error memoryerror
- numpy.core._exceptions.MemoryError: Unable to allocate xxx GB
- Matlab matrix transpose function
- Modification scheme of binary files in dot matrix font library
- Pytorch corresponding point multiplication and matrix multiplication
- Error: The size of the connection buffer (131072) was not large enough
- error: Eigen does not name a type Eigen::Matrix
- Java long type error: error: integer number too large
- mysql5.7.26:[ERR] 1118 – Row size too large (> 8126)
- Solution to “initializing the Oracle asmlib driver: [failed]”
- Server (for example: HTTP) has a large number of time_ Solutions to wait
- Can’t find Python executable “D:\python3\python.exe”, you can set the PYTHON env variable.
- Error in plot.new() : figure margins too large
- Nginx upload error 413 request entity too large