我是Tensorflow的新手,请帮忙修正这个错误。我使用了Tensorflow教程代码,使用get_input_fn将pandas数据帧输入转换为tensors,但我还是遇到了这个错误。一点帮助也不为过。在
---------------------------------------------------------------------------
AttributeError Traceback (most recent call last)
<ipython-input-4-8ac4f79a2981> in <module>()
114
115 if __name__ == '__main__':
--> 116 main()
<ipython-input-4-8ac4f79a2981> in main()
105 Xtrain = pd.concat([Xtrain, ytrain], axis = 1)
106 Xtest = pd.concat([Xtest, ytest], axis = 1)
--> 107 Tensors(Xtrain, Xtest)
<ipython-input-4-8ac4f79a2981> in Tensors(Xtrain, Xtest)
30 print(feature_cols)
31 nnreg = tf.contrib.learn.DNNRegressor(feature_columns =
feature_cols, hidden_units = [10, 10])
---> 32 nnreg.fit(input_fn = get_input_fn(Xtrain), steps = 5000)
33 ev = nnreg.evaluate(input_fn = get_input_fn(Xtest, num_epochs = 1, shuffle = False))
34 loss_score = ev['loss']
<ipython-input-4-8ac4f79a2981> in get_input_fn(data, num_epochs, shuffle)
22 y = tf.constant(data[label].values),
23 num_epochs = num_epochs,
---> 24 shuffle = shuffle)
25
26 def Tensors(Xtrain, Xtest):
C:\Users\user\Anaconda3\lib\site-
packages\tensorflow\python\estimator\inputs\pandas_io.py in pandas_input_fn(x, y, batch_size, num_epochs, shuffle, queue_capacity, num_threads, target_column)
83 'Cannot use name %s for target column: DataFrame already has a '
84 'column with that name: %s' % (target_column, x.columns))
---> 85 if not np.array_equal(x.index, y.index):
86 raise ValueError('Index for x and y are mismatched.\nIndex for x: %s\n'
87 'Index for y: %s\n' % (x.index, y.index))
AttributeError: 'dict' object has no attribute 'index'
这是pandas dataframe的get_input_fn()。在
^{pr2}$
目前没有回答
相关问题 更多 >
编程相关推荐