试图将'n'转换为张量并失败。错误:不支持任何值

时间:2018-05-24 03:36:50

标签: 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

更新 在应用了一些错误已经改变的建议之后,错误是我在这篇文章中遇到prio的事情,这意味着我在圈子里跑来跑去:)

这是完整的错误:

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

1 个答案:

答案 0 :(得分:1)

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

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),当它到达deque时,它会检查该参数。只需删除batch_size或将其设置为您的列车大小的数字