我正在尝试使用DNN多元回归来估计以2个要素作为输入的输出。以下是我的代码(注意数据是干净的,绝对没有NaN存在)。
train_set, test_set = train_test_split(Ha_Noi, test_size=0.2, random_state = random.randint(20, 200))
# Training Data
train_X = np.array(train_set['longwait_percent2'])
train_X2 = np.array(train_set['accept_rate_timeT'])
train_Y = np.array(train_set['accept_rate'])
n_samples = train_X.shape[0]
#Testing Data
Xtest = np.array(test_set['longwait_percent2'])
Xtest2 = np.array(test_set['accept_rate_timeT'])
Ytest = np.array(test_set['accept_rate'])
#Deep Neural Network Regressor
feature_column1 = learn.infer_real_valued_columns_from_input(train_X)
feature_column2 = learn.infer_real_valued_columns_from_input(train_X2)
regressor = learn.DNNRegressor(feature_columns=[feature_column1, feature_column2], hidden_units=[20, 10])
regressor.fit(x = [feature_column1, feature_column2],y = train_Y, steps= STEPS, batch_size= BATCH_SIZE)
当我执行此代码时,它会不断向我提供错误消息:" AttributeError:' list'对象没有属性' dtype'"。我还注意到,如果我的x变量是 1D -array而不是2D,代码可以正常工作。有谁知道如何解决这个问题?