# 计算总平方和ss_total = tfreduce_sumtfsquareX_true - mean这段代码报错如下AttributeError DType object has no attribute kind该怎么修改代码
该错误可能是由于X_true或mean的数据类型不正确导致的。可以尝试将它们的数据类型转换为正确的类型。例如,如果X_true和mean应该是浮点数类型,可以使用tf.cast函数将它们转换为浮点数类型:
X_true = tf.cast(X_true, tf.float32) mean = tf.cast(mean, tf.float32)
然后再执行计算总平方和的代码:
ss_total = tf.reduce_sum(tf.square(X_true - mean))
原文地址: http://www.cveoy.top/t/topic/i0gb 著作权归作者所有。请勿转载和采集!