python3.x - python3.5的numpy设置array为float64,报错"name float64 is not defined"
伊谢尔伦
伊谢尔伦 2017-04-17 17:48:06
0
2
1242
trainWeights = gradDescent(np.array(trainingSet,dtype=float64), trainingLabels)

把dtype设置为float64会报错 NameError: name 'float64' is not defined

但是如果去掉"dtype=float64"会出现warning:DataConversionWarning: Data with input dtype <U3 was converted to float64 by MinMaxScaler.
warnings.warn(msg, DataConversionWarning) 提醒被转换成了float64

请问应该如何显式转换呢?

伊谢尔伦
伊谢尔伦

小伙看你根骨奇佳,潜力无限,来学PHP伐。

reply all(2)
阿神

Is it possible that you didn’t import float64
Of course it’s not right for you to import like this literally. .
Like this. .

import numpy as np
dtype=np.float64
刘奇

float64 is a class under numpy. If you want to use float64 without modification, you need to import it like this

import numpy as np
from numpy import float64


c = np.array([], dtype=float64)

If there is no from numpy import float64, use it like this

c = np.array([], dtype=np.float64)
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template