Reputation: 431
I have a list of list of size 3 that is:
positions_train = [[0.300,0.4500,0.5900,0.7812],[0.1200,0.3400,0.6700,0.8400],[0.210,0.2900,0.500,0.6700]]
I want to reshape it such that it becomes (3,4) of type float64 which I can give it to a fully connected neural network because otherwise it gives me an error.
I've tried reshaping it but it doesn't work. I also tried:
np.asarray(positions_train)
It converts it to size (10,) of type object.
Help would be appreciated.
Upvotes: 1
Views: 38
Reputation: 51653
Reshape the array?
import numpy as np
positions_train = [[0.300,0.4500,0.5900,0.7812],
[0.1200,0.3400,0.6700,0.8400],
[0.210,0.2900,0.500,0.6700]]
k = np.asarray(positions_train).reshape((3,4))
print(k)
print(k.dtype)
Output:
[[0.3 0.45 0.59 0.7812]
[0.12 0.34 0.67 0.84 ]
[0.21 0.29 0.5 0.67 ]]
float64
Upvotes: 2