我有一个大小为3的列表,即:
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]]
我想对其进行整形,使其变为float64类型的(3,4),我可以将其提供给完全连接的神经网络,否则会给我一个错误。
我尝试过重塑它,但是它不起作用。我也尝试过:
np.asarray(positions_train)
将其转换为类型object的大小(10,)。
我们将不胜感激。
答案 0 :(得分:2)
重塑数组?
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)
输出:
[[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