Python 使用TensorForestEstimator训练Tensorflow随机林时的类型错误
当尝试使用TensorForestEstimator训练Tensorflow随机林时,我得到一个类型错误Python 使用TensorForestEstimator训练Tensorflow随机林时的类型错误,python,python-3.x,machine-learning,tensorflow,random-forest,Python,Python 3.x,Machine Learning,Tensorflow,Random Forest,当尝试使用TensorForestEstimator训练Tensorflow随机林时,我得到一个类型错误 TypeError: Input 'input_data' of 'CountExtremelyRandomStats' Op has type float64 that does not match expected type of float32. 我尝试过使用Python2.7和Python3,并且尝试过使用tf.cast()将所有内容放入float32中,但没有任何帮助。我已经检查
TypeError: Input 'input_data' of 'CountExtremelyRandomStats' Op has type float64 that does not match expected type of float32.
我尝试过使用Python2.7和Python3,并且尝试过使用tf.cast()将所有内容放入float32中,但没有任何帮助。我已经检查了执行时的数据类型,它是float32。问题似乎不是我提供的数据(所有浮动的csv),所以我不确定从这里走到哪里
任何我可以尝试的建议都将不胜感激
代码:
您使用tf.cast的方式不正确
tf.cast(training_set, tf.float32) #error occurs with/without casts
应该是
training_set = tf.cast(training_set, tf.float32)
tf.cast是非就地方法,与任何其他操作一样,它是张量流op,需要分配和运行。您好,我也遇到过类似问题,但此解决方案对我不起作用?我不确定我的问题是否与此相同?
training_set = tf.cast(training_set, tf.float32)