Python 带tensorflow回归的多重标签
我想在tensorflow中建立一个多标签模型。我在这里看到了一个相关的问题:,但无法使解决方案起作用 代码来自tensorflow教程 在我的回归中,我将标签维度设置为2Python 带tensorflow回归的多重标签,python,numpy,tensorflow,Python,Numpy,Tensorflow,我想在tensorflow中建立一个多标签模型。我在这里看到了一个相关的问题:,但无法使解决方案起作用 代码来自tensorflow教程 在我的回归中,我将标签维度设置为2 regressor = tf.estimator.DNNRegressor(feature_columns=feature_cols, label_dimension=2,
regressor = tf.estimator.DNNRegressor(feature_columns=feature_cols,
label_dimension=2,
hidden_units=[10, 10],
model_dir="/tmp/boston_model")
通过我的努力,我得到:
Traceback (most recent call last):
File "./boston.py", line 85, in <module>
tf.app.run()
File "/home/jillian/.eb/software/machine-learning/1.00/lib/python3.6/site-packages/tensorflow/python/platform/app.py", line 48, in run
_sys.exit(main(_sys.argv[:1] + flags_passthrough))
File "./boston.py", line 67, in main
regressor.train(input_fn=get_input_fn(training_set), steps=5000)
File "./boston.py", line 43, in get_input_fn
shuffle=shuffle)
File "/home/jillian/.eb/software/machine-learning/1.00/lib/python3.6/site-packages/tensorflow/python/estimator/inputs/pandas_io.py", line 87, in pand
as_input_fn
'Index for y: %s\n' % (x.index, y.index))
ValueError: Index for x and y are mismatched.
Index for x: RangeIndex(start=0, stop=400, step=1)
Index for y: <built-in method index of list object at 0x7f6f64a5bb48>
回溯(最近一次呼叫最后一次):
文件“/boston.py”,第85行,在
tf.app.run()
文件“/home/jillian/.eb/software/machine learning/1.00/lib/python3.6/site packages/tensorflow/python/platform/app.py”,第48行,运行中
_系统出口(主(_sys.argv[:1]+标志_passthrough))
文件“/boston.py”,第67行,主
回归器.train(输入=get\u输入=get\u fn(训练集),步长=5000)
文件“/boston.py”,第43行,在get\u input\u fn中
洗牌
文件“/home/jillian/.eb/software/machine learning/1.00/lib/python3.6/site packages/tensorflow/python/estimator/inputs/pandas_io.py”,第87行,在pand中
作为输入
'y的索引:%s\n'(x.Index,y.Index))
ValueError:x和y的索引不匹配。
x的索引:范围索引(开始=0,停止=400,步骤=1)
y的索引:
我还尝试将y设置为numpy数组而不是列表。您的功能的值是多少?
Traceback (most recent call last):
File "./boston.py", line 85, in <module>
tf.app.run()
File "/home/jillian/.eb/software/machine-learning/1.00/lib/python3.6/site-packages/tensorflow/python/platform/app.py", line 48, in run
_sys.exit(main(_sys.argv[:1] + flags_passthrough))
File "./boston.py", line 67, in main
regressor.train(input_fn=get_input_fn(training_set), steps=5000)
File "./boston.py", line 43, in get_input_fn
shuffle=shuffle)
File "/home/jillian/.eb/software/machine-learning/1.00/lib/python3.6/site-packages/tensorflow/python/estimator/inputs/pandas_io.py", line 87, in pand
as_input_fn
'Index for y: %s\n' % (x.index, y.index))
ValueError: Index for x and y are mismatched.
Index for x: RangeIndex(start=0, stop=400, step=1)
Index for y: <built-in method index of list object at 0x7f6f64a5bb48>