Is there way to initialize a numpy array of a shape and add to it? I will explain what I need with a list example. If I want to create a list of objects generated in a loop,
To initialize a numpy array with a specific matrix:
import numpy as np mat = np.array([[1, 1, 0, 0, 0], [0, 1, 0, 0, 1], [1, 0, 0, 1, 1], [0, 0, 0, 0, 0], [1, 0, 1, 0, 1]]) print mat.shape print mat
output:
(5, 5) [[1 1 0 0 0] [0 1 0 0 1] [1 0 0 1 1] [0 0 0 0 0] [1 0 1 0 1]]