尝试将’n’转换为张量但失败了。错误:不支持None值

我在这上面已经深陷其中,无法让这个(看似)简单的线性回归工作。我知道答案可能就在眼前,但我觉得我已经盯着它太久了,看不到了 :).

回溯信息:

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),当它到达deque时,它会检查该参数。只要删除batch_size或将其设置为训练数据集大小的因数即可

Related Posts

使用LSTM在Python中预测未来值

这段代码可以预测指定股票的当前日期之前的值,但不能预测…

如何在gensim的word2vec模型中查找双词组的相似性

我有一个word2vec模型,假设我使用的是googl…

dask_xgboost.predict 可以工作但无法显示 – 数据必须是一维的

我试图使用 XGBoost 创建模型。 看起来我成功地…

ML Tuning – Cross Validation in Spark

我在https://spark.apache.org/…

如何在React JS中使用fetch从REST API获取预测

我正在开发一个应用程序,其中Flask REST AP…

如何分析ML.NET中多类分类预测得分数组?

我在ML.NET中创建了一个多类分类项目。该项目可以对…

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注