Tensorflow张量形状错误

时间:2018-08-01 17:58:08

标签: python tensorflow tensor

培训数据列

2个字符串类型数据,3个整数类型数据,1个浮点类型数据作为y列

模型:Tensorflow Boosted Trees Regressor

构建模型列

2个字符串类型数据:分类列

3个整数类型数据:存储桶

然后,将以上5列转换为指标列

但是,我收到以下Tensor形状不兼容错误。

Traceback (most recent call last):
  File "main.py", line 191, in <module>
tf.app.run(main=main, argv=[sys.argv[0]] + unparsed)
  File "/.../.../.local/lib/python3.6/site-packages/tensorflow/python/platform/app.py", line 125, in run
_sys.exit(main(argv))
  File "main.py", line 170, in main
experiment.train_and_evaluate()
  File "/.../.../.local/lib/python3.6/site-packages/tensorflow/contrib/learn/python/learn/experiment.py", line 671, in train_and_evaluate
self.train(delay_secs=0)
  File "/.../.../.local/lib/python3.6/site-packages/tensorflow/contrib/learn/python/learn/experiment.py", line 389, in train
saving_listeners=self._saving_listeners)
  File "/.../.../.local/lib/python3.6/site-packages/tensorflow/contrib/learn/python/learn/experiment.py", line 881, in _call_train
saving_listeners=saving_listeners)
  File "/.../.../.local/lib/python3.6/site-packages/tensorflow/python/estimator/estimator.py", line 366, in train
loss = self._train_model(input_fn, hooks, saving_listeners)
  File "/.../.../.local/lib/python3.6/site-packages/tensorflow/python/estimator/estimator.py", line 1119, in _train_model
return self._train_model_default(input_fn, hooks, saving_listeners)
 File "/.../.../.local/lib/python3.6/site-packages/tensorflow/python/estimator/estimator.py", line 1132, in _train_model_default
features, labels, model_fn_lib.ModeKeys.TRAIN, self.config)
  File "/.../.../.local/lib/python3.6/site-packages/tensorflow/python/estimator/estimator.py", line 1107, in _call_model_fn
model_fn_results = self._model_fn(features=features, **kwargs)
  File "/.../.../.local/lib/python3.6/site-packages/tensorflow/python/estimator/canned/boosted_trees.py", line 929, in _model_fn
n_batches_per_layer, config)
  File "/.../.../.local/lib/python3.6/site-packages/tensorflow/python/estimator/canned/boosted_trees.py", line 650, in _bt_model_fn
logits=logits)
  File "/.../.../.local/lib/python3.6/site-packages/tensorflow/python/estimator/canned/head.py", line 239, in create_estimator_spec
regularization_losses))
  File "/.../.../.local/lib/python3.6/site-packages/tensorflow/python/estimator/canned/head.py", line 1506, in _create_tpu_estimator_spec
train_op = train_op_fn(regularized_training_loss)
  File "/.../.../.local/lib/python3.6/site-packages/tensorflow/python/estimator/canned/boosted_trees.py", line 611, in _train_op_fn
array_ops.stack(stats_summaries, axis=0), stamp_token)
  File "/.../.../.local/lib/python3.6/site-packages/tensorflow/python/ops/data_flow_ops.py", line 1286, in apply_grad
grad.get_shape().assert_is_compatible_with(self._shape)
  File "/.../.../.local/lib/python3.6/site-packages/tensorflow/python/framework/tensor_shape.py", line 847, in assert_is_compatible_with
raise ValueError("Shapes %s and %s are incompatible" % (self, other))
ValueError: Shapes (0,) and (0, 63, 2, 2) are incompatible

我的问题是:张量的哪些形状分别是(0,)和(0,63,2,2)?后一种形状对我来说没有意义。

0 个答案:

没有答案