tensorflow - 尝试将 'n' 转换为张量但失败。错误: None values not supported

标签 tensorflow machine-learning

我已经深入研究了这个,但似乎无法让这个(看起来)简单的线性回归发挥作用。我知道答案可能就在我面前,但我想我已经盯着它看太久了:)。

回溯:

Traceback (most recent call last):
  File "/usr/local/lib/python3.6/site-packages/tensorflow/python/framework/op_def_library.py", line 510, in _apply_op_helper
    preferred_dtype=default_dtype)
  File "/usr/local/lib/python3.6/site-packages/tensorflow/python/framework/ops.py", line 1022, in internal_convert_to_tensor
    ret = conversion_func(value, dtype=dtype, name=name, as_ref=as_ref)
  File "/usr/local/lib/python3.6/site-packages/tensorflow/python/framework/constant_op.py", line 233, in _constant_tensor_conversion_function
    return constant(v, dtype=dtype, name=name)
  File "/usr/local/lib/python3.6/site-packages/tensorflow/python/framework/constant_op.py", line 212, in constant
    value, dtype=dtype, shape=shape, verify_shape=verify_shape))
  File "/usr/local/lib/python3.6/site-packages/tensorflow/python/framework/tensor_util.py", line 401, in make_tensor_proto
    raise ValueError("None values not supported.")
ValueError: None values not supported.

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/local/lib/python3.6/site-packages/tensorflow/python/framework/op_def_library.py", line 524, in _apply_op_helper
    values, as_ref=input_arg.is_ref).dtype.name
  File "/usr/local/lib/python3.6/site-packages/tensorflow/python/framework/ops.py", line 1022, in internal_convert_to_tensor
    ret = conversion_func(value, dtype=dtype, name=name, as_ref=as_ref)
  File "/usr/local/lib/python3.6/site-packages/tensorflow/python/framework/constant_op.py", line 233, in _constant_tensor_conversion_function
    return constant(v, dtype=dtype, name=name)
  File "/usr/local/lib/python3.6/site-packages/tensorflow/python/framework/constant_op.py", line 212, in constant
    value, dtype=dtype, shape=shape, verify_shape=verify_shape))
  File "/usr/local/lib/python3.6/site-packages/tensorflow/python/framework/tensor_util.py", line 401, in make_tensor_proto
    raise ValueError("None values not supported.")
ValueError: None values not supported.

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "flights.py", line 143, in <module>
    regressor.train(input_fn=training_input_fn, steps=10000)
  File "/usr/local/lib/python3.6/site-packages/tensorflow/python/estimator/estimator.py", line 314, in train
    loss = self._train_model(input_fn, hooks, saving_listeners)
  File "/usr/local/lib/python3.6/site-packages/tensorflow/python/estimator/estimator.py", line 740, in _train_model
    input_fn, model_fn_lib.ModeKeys.TRAIN))
  File "/usr/local/lib/python3.6/site-packages/tensorflow/python/estimator/estimator.py", line 603, in _get_features_and_labels_from_input_fn
    result = self._call_input_fn(input_fn, mode)
  File "/usr/local/lib/python3.6/site-packages/tensorflow/python/estimator/estimator.py", line 694, in _call_input_fn
    return input_fn(**kwargs)
  File "/usr/local/lib/python3.6/site-packages/tensorflow/python/estimator/inputs/pandas_io.py", line 110, in input_fn
    features = queue.dequeue_many(batch_size)
  File "/usr/local/lib/python3.6/site-packages/tensorflow/python/ops/data_flow_ops.py", line 475, in dequeue_many
    self._queue_ref, n=n, component_types=self._dtypes, name=name)
  File "/usr/local/lib/python3.6/site-packages/tensorflow/python/ops/gen_data_flow_ops.py", line 2445, in _queue_dequeue_many_v2
    component_types=component_types, timeout_ms=timeout_ms, name=name)
  File "/usr/local/lib/python3.6/site-packages/tensorflow/python/framework/op_def_library.py", line 528, in _apply_op_helper
    (input_name, err))
ValueError: Tried to convert 'n' to a tensor and failed. Error: None values not supported.

代码:https://pastebin.com/M9arSCQa

数据文件:https://storage.googleapis.com/stackquestion2/201701.csv

更新 在应用了一些建议之后,错误发生了变化,但是,这个错误是我在这篇文章中遇到的,这意味着我在原地踏步:)

这是完整的错误:

tensorflow.python.framework.errors_impl.OutOfRangeError: FIFOQueue '_0_enqueue_input/fifo_queue' is closed and has insufficient elements (requested 128, current size 0)
     [[Node: fifo_queue_DequeueUpTo = QueueDequeueUpToV2[component_types=[DT_INT64, DT_STRING, DT_STRING, DT_DOUBLE, DT_STRING, ..., DT_STRING, DT_STRING, DT_STRING, DT_FLOAT, DT_FLOAT], timeout_ms=-1, _device="/job:localhost/replica:0/task:0/device:CPU:0"](enqueue_input/fifo_queue, fifo_queue_DequeueUpTo/n)]]

最新代码:https://pastebin.com/TvCw0rVw

最佳答案

我认为你的问题就在这里,

training_input_fn = tf.estimator.inputs.pandas_input_fn(x=training_data, y=training_label, batch_size=None, shuffle=True, num_epochs=None)

您将batch_size设置为None,这会验证默认参数(128),并且当它到达双端队列时,它会检查该参数。只需删除batch_size或将其设置为列车大小的一个因素

关于tensorflow - 尝试将 'n' 转换为张量但失败。错误: None values not supported,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50500529/

相关文章:

machine-learning - Keras——没有带有广播的 Dot 层?

machine-learning - 如何获取新段落的段落向量?

tensorflow - 形状必须等于等级,但必须为2和1

graph - 如何在tensorflow MNIST教程中输出预测值(标签)?

python - Tensorflow 模型输入形状错误 : Input 0 of layer sequential_11 incompatible with layer: rank undefined, 但层需要定义等级

machine-learning - 有没有适用于 MATLAB 的快速提升工具箱?

c# - 有签名识别的代码或算法吗?

machine-learning - 为什么以及何时需要深度强化学习而不是 q 学习?

python - Tensorflow 2.0 中的多输入 CNN 没有执行任何操作

python - 在GPU上预加载整个数据集以训练Keras模型