tensorflow.python.framework.errors_impl.InvalidArgumentError: Quoted field has to end with quote fol

本文介绍在使用TensorFlow进行数据读取时遇到的Quoted field has to end with quote followed by delim or end错误,并提供了一种通过在数据集上应用tf.contrib.data.ignore_errors()来忽略错误数据项的解决方案。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

Traceback (most recent call last):
  File "/usr/local/lib/python3.5/dist-packages/tensorflow/python/client/session.py", line 1292, in _do_call
    return fn(*args)
  File "/usr/local/lib/python3.5/dist-packages/tensorflow/python/client/session.py", line 1277, in _run_fn
    options, feed_dict, fetch_list, target_list, run_metadata)
  File "/usr/local/lib/python3.5/dist-packages/tensorflow/python/client/session.py", line 1367, in _call_tf_sessionrun
    run_metadata)
tensorflow.python.framework.errors_impl.InvalidArgumentError: Quoted field has to end with quote followed by delim or end
	 [[{{node DecodeCSV}} = DecodeCSV[OUT_TYPE=[DT_INT32, DT_INT32, DT_INT32, DT_INT32, DT_INT32, ..., DT_STRING, DT_STRING, DT_STRING, DT_STRING, DT_FLOAT], field_delim=",", na_value="", select_cols=[], use_quote_delim=true, _device="/device:CPU:0"](arg0, strided_slice/stack, strided_slice/stack, strided_slice/stack, strided_slice/stack, strided_slice/stack, strided_slice/stack, strided_slice/stack, strided_slice/stack, strided_slice/stack, strided_slice/stack, strided_slice/stack, strided_slice/stack, strided_slice/stack, strided_slice/stack, strided_slice/stack, strided_slice/stack, strided_slice/stack, strided_slice/stack, strided_slice/stack, strided_slice/stack, strided_slice/stack, strided_slice/stack, strided_slice/stack, strided_slice/stack, strided_slice/stack, strided_slice/stack, strided_slice/stack, strided_slice/stack, strided_slice/stack, strided_slice/stack, strided_slice/stack, strided_slice/stack, strided_slice/stack, strided_slice/stack, strided_slice/stack, strided_slice/stack, strided_slice/stack, strided_slice/stack, strided_slice/stack, strided_slice/stack, strided_slice/stack, strided_slice/stack, strided_slice/stack, strided_slice/stack, strided_slice/stack, strided_slice/stack, strided_slice/stack, strided_slice/stack, strided_slice/stack, DecodeCSV/record_defaults_49, DecodeCSV/record_defaults_49, DecodeCSV/record_defaults_49, DecodeCSV/record_defaults_49, DecodeCSV/record_defaults_49, DecodeCSV/record_defaults_49, DecodeCSV/record_defaults_49, DecodeCSV/record_defaults_49, DecodeCSV/record_defaults_49, DecodeCSV/record_defaults_49, DecodeCSV/record_defaults_49, DecodeCSV/record_defaults_49, DecodeCSV/record_defaults_49, DecodeCSV/record_defaults_49, DecodeCSV/record_defaults_49, strided_slice/stack, strided_slice/stack, strided_slice/stack, strided_slice/stack, strided_slice/stack, strided_slice/stack, strided_slice/stack, strided_slice/stack, DecodeCSV/record_defaults_72, DecodeCSV/record_defaults_72, DecodeCSV/record_defaults_72, DecodeCSV/record_defaults_72, DecodeCSV/record_defaults_72, DecodeCSV/record_defaults_72, DecodeCSV/record_defaults_72, DecodeCSV/record_defaults_72, DecodeCSV/record_defaults_72, DecodeCSV/record_defaults_72, DecodeCSV/record_defaults_49)]]
	 [[{{node IteratorGetNext}} = IteratorGetNext[output_shapes=[[?], [?], [?], [?], [?], ..., [?,?], [?], [?], [?], [?]], output_types=[DT_FLOAT, DT_INT32, DT_FLOAT, DT_INT32, DT_FLOAT, ..., DT_INT32, DT_INT32, DT_INT32, DT_INT32, DT_FLOAT], _device="/job:localhost/replica:0/task:0/device:CPU:0"](OneShotIterator)]]
	 [[{{node input_layer/userOs_bucketized_embedding/userOs_bucketized_embedding_weights/SparseReshape/_7765}} = _Recv[client_terminated=false, recv_device="/job:localhost/replica:0/task:0/device:GPU:0", send_device="/job:localhost/replica:0/task:0/device:CPU:0", send_device_incarnation=1, tensor_name="edge_3975_...rseReshape", tensor_type=DT_INT64, _device="/job:localhost/replica:0/task:0/device:GPU:0"]()]]

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/var/din_209_test/dinPregrantModel/train.py", line 249, in <module>
    tf.app.run(main=main)
  File "/usr/local/lib/python3.5/dist-packages/tensorflow/python/platform/app.py", line 125, in run
    _sys.exit(main(argv))
  File "/var/din_209_test/dinPregrantModel/train.py", line 170, in main
    tf.estimator.train_and_evaluate(model, train_spec, eval_spec)
  File "/usr/local/lib/python3.5/dist-packages/tensorflow/python/estimator/training.py", line 471, in train_and_evaluate
    return executor.run()
  File "/usr/local/lib/python3.5/dist-packages/tensorflow/python/estimator/training.py", line 610, in run
    return self.run_local()
  File "/usr/local/lib/python3.5/dist-packages/tensorflow/python/estimator/training.py", line 711, in run_local
    saving_listeners=saving_listeners)
  File "/usr/local/lib/python3.5/dist-packages/tensorflow/python/estimator/estimator.py", line 356, in train
    loss = self._train_model(input_fn, hooks, saving_listeners)
  File "/usr/local/lib/python3.5/dist-packages/tensorflow/python/estimator/estimator.py", line 1181, in _train_model
    return self._train_model_default(input_fn, hooks, saving_listeners)
  File "/usr/local/lib/python3.5/dist-packages/tensorflow/python/estimator/estimator.py", line 1215, in _train_model_default
    saving_listeners)
  File "/usr/local/lib/python3.5/dist-packages/tensorflow/python/estimator/estimator.py", line 1409, in _train_with_estimator_spec
    _, loss = mon_sess.run([estimator_spec.train_op, estimator_spec.loss])
  File "/usr/local/lib/python3.5/dist-packages/tensorflow/python/training/monitored_session.py", line 671, in run
    run_metadata=run_metadata)
  File "/usr/local/lib/python3.5/dist-packages/tensorflow/python/training/monitored_session.py", line 1148, in run
    run_metadata=run_metadata)
  File "/usr/local/lib/python3.5/dist-packages/tensorflow/python/training/monitored_session.py", line 1239, in run
    raise six.reraise(*original_exc_info)
  File "/usr/local/lib/python3.5/dist-packages/six.py", line 693, in reraise
    raise value
  File "/usr/local/lib/python3.5/dist-packages/tensorflow/python/training/monitored_session.py", line 1224, in run
    return self._sess.run(*args, **kwargs)
  File "/usr/local/lib/python3.5/dist-packages/tensorflow/python/training/monitored_session.py", line 1296, in run
    run_metadata=run_metadata)
  File "/usr/local/lib/python3.5/dist-packages/tensorflow/python/training/monitored_session.py", line 1076, in run
    return self._sess.run(*args, **kwargs)
  File "/usr/local/lib/python3.5/dist-packages/tensorflow/python/client/session.py", line 887, in run
    run_metadata_ptr)
  File "/usr/local/lib/python3.5/dist-packages/tensorflow/python/client/session.py", line 1110, in _run
    feed_dict_tensor, options, run_metadata)
  File "/usr/local/lib/python3.5/dist-packages/tensorflow/python/client/session.py", line 1286, in _do_run
    run_metadata)
  File "/usr/local/lib/python3.5/dist-packages/tensorflow/python/client/session.py", line 1308, in _do_call
    raise type(e)(node_def, op, message)
tensorflow.python.framework.errors_impl.InvalidArgumentError: Quoted field has to end with quote followed by delim or end
	 [[{{node DecodeCSV}} = DecodeCSV[OUT_TYPE=[DT_INT32, DT_INT32, DT_INT32, DT_INT32, DT_INT32, ..., DT_STRING, DT_STRING, DT_STRING, DT_STRING, DT_FLOAT], field_delim=",", na_value="", select_cols=[], use_quote_delim=true, _device="/device:CPU:0"](arg0, strided_slice/stack, strided_slice/stack, strided_slice/stack, strided_slice/stack, strided_slice/stack, strided_slice/stack, strided_slice/stack, strided_slice/stack, strided_slice/stack, strided_slice/stack, strided_slice/stack, strided_slice/stack, strided_slice/stack, strided_slice/stack, strided_slice/stack, strided_slice/stack, strided_slice/stack, strided_slice/stack, strided_slice/stack, strided_slice/stack, strided_slice/stack, strided_slice/stack, strided_slice/stack, strided_slice/stack, strided_slice/stack, strided_slice/stack, strided_slice/stack, strided_slice/stack, strided_slice/stack, strided_slice/stack, strided_slice/stack, strided_slice/stack, strided_slice/stack, strided_slice/stack, strided_slice/stack, strided_slice/stack, strided_slice/stack, strided_slice/stack, strided_slice/stack, strided_slice/stack, strided_slice/stack, strided_slice/stack, strided_slice/stack, strided_slice/stack, strided_slice/stack, strided_slice/stack, strided_slice/stack, strided_slice/stack, strided_slice/stack, DecodeCSV/record_defaults_49, DecodeCSV/record_defaults_49, DecodeCSV/record_defaults_49, DecodeCSV/record_defaults_49, DecodeCSV/record_defaults_49, DecodeCSV/record_defaults_49, DecodeCSV/record_defaults_49, DecodeCSV/record_defaults_49, DecodeCSV/record_defaults_49, DecodeCSV/record_defaults_49, DecodeCSV/record_defaults_49, DecodeCSV/record_defaults_49, DecodeCSV/record_defaults_49, DecodeCSV/record_defaults_49, DecodeCSV/record_defaults_49, strided_slice/stack, strided_slice/stack, strided_slice/stack, strided_slice/stack, strided_slice/stack, strided_slice/stack, strided_slice/stack, strided_slice/stack, DecodeCSV/record_defaults_72, DecodeCSV/record_defaults_72, DecodeCSV/record_defaults_72, DecodeCSV/record_defaults_72, DecodeCSV/record_defaults_72, DecodeCSV/record_defaults_72, DecodeCSV/record_defaults_72, DecodeCSV/record_defaults_72, DecodeCSV/record_defaults_72, DecodeCSV/record_defaults_72, DecodeCSV/record_defaults_49)]]
	 [[{{node IteratorGetNext}} = IteratorGetNext[output_shapes=[[?], [?], [?], [?], [?], ..., [?,?], [?], [?], [?], [?]], output_types=[DT_FLOAT, DT_INT32, DT_FLOAT, DT_INT32, DT_FLOAT, ..., DT_INT32, DT_INT32, DT_INT32, DT_INT32, DT_FLOAT], _device="/job:localhost/replica:0/task:0/device:CPU:0"](OneShotIterator)]]
	 [[{{node input_layer/userOs_bucketized_embedding/userOs_bucketized_embedding_weights/SparseReshape/_7765}} = _Recv[client_terminated=false, recv_device="/job:localhost/replica:0/task:0/device:GPU:0", send_device="/job:localhost/replica:0/task:0/device:CPU:0", send_device_incarnation=1, tensor_name="edge_3975_...rseReshape", tensor_type=DT_INT64, _device="/job:localhost/replica:0/task:0/device:GPU:0"]()]]

在tensorflow进行数据读取时,经常出现上述错误,于是在数据处理的时候加入

dataset = dataset.apply(tf.contrib.data.ignore_errors())

忽略数据某几条出错的操作,就完美解决

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值