AttributeError Traceback most recent call lastCell In23 line 3 1 #将房价转换为列向量---- 3 Y_train = tfconstanty_trainreshape-11tffloat32 5 Y_test = tfconstanty_testreshape
上面的代码中,第三行出错了。错误提示为:'Series' object has no attribute 'reshape'。这是因为y_train是一个Series对象,而Series对象没有reshape方法。可以使用numpy中的reshape方法来进行转换。
修改代码如下:
import numpy as np
#将房价转换为列向量
Y_train = tf.constant(np.array(y_train).reshape(-1,1),tf.float32)
Y_test = tf.constant(np.array(y_test).reshape(-1,1),tf.float32)
原文地址: http://www.cveoy.top/t/topic/hrJn 著作权归作者所有。请勿转载和采集!