I'm reading data (numbers) from a file into a list, as follows:
weight_file = open(model_name, 'r').readlines()
weights = weight_file[6:]
It seems that I can't read them straight into a numpy.array because the first rows of the file contains words.
So now, in weights I have a list as follows: [['1 2 3'] ['4 5 6']]
Now I want to convert it into a numpy.array. I tried this:
weights_np = np.array([])
for weight in weights:
weights_np = np.append(weights_np, weight.split())
What this does is create a single vector: [1, 2, 3, 4, 5, 6], but I need it to be represented as some kind of matrix - like a list of lists. How can I do that?
Thanks