9951 explained code solutions for 126 technologies


python-numpyHow to load Numpy matrix from text file


import numpy as np

matrix = np.loadtxt('/tmp/matrix.txt')ctrl + c
import numpy as np

load Numpy module for Python

.loadtxt

load array from text file

/tmp/matrix.txt

path to text file that was previously saved with savetxt()

matrix

will contain loaded matrix