类型错误:预期的二进制或 unicode 字符串,得到 2282667 [英] TypeError: Expected binary or unicode string, got 2282667

查看:29
本文介绍了类型错误:预期的二进制或 unicode 字符串,得到 2282667的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我运行此代码 boston.py 使用不同的数据,但我不断收到此错误.

I run this code boston.py with different data, but I keep getting this error.

sys:1: DtypeWarning: Columns (5,7,8) have mixed types. Specify dtype option on import or set low_memory=False.
INFO:tensorflow:Using default config.
INFO:tensorflow:Using config: {'_model_dir': None, '_save_checkpoints_secs': 600, '_num_ps_replicas': 0, '_keep_checkpoint_max': 5, '_tf_random_seed': None, '_task_type': None, '_environment': 'local', '_is_chief': True, '_cluster_spec': <tensorflow.python.training.server_lib.ClusterSpec object at 0x11d0b50d0>, '_tf_config': gpu_options {
per_process_gpu_memory_fraction: 1
}
, '_num_worker_replicas': 0, '_task_id': 0, '_save_summary_steps': 100, '_save_checkpoints_steps': None, '_evaluation_master': '', '_keep_checkpoint_every_n_hours': 10000, '_master': ''}
Traceback (most recent call last):
File "runDNN.py", line 73, in <module>
tf.app.run()
File "/Users/soalamro/tensorflow/lib/python2.7/site-packages/tensorflow/python/platform/app.py", line 48, in run
_sys.exit(main(_sys.argv[:1] + flags_passthrough))
File "runDNN.py", line 59, in main
regressor.fit(input_fn=lambda: input_fn(training_set), steps=5000)
File "/Users/soalamro/tensorflow/lib/python2.7/site-packages/tensorflow/python/util/deprecation.py", line 281, in new_func
return func(*args, **kwargs)
File "/Users/soalamro/tensorflow/lib/python2.7/site-packages/tensorflow/contrib/learn/python/learn/estimators/estimator.py", line 430, in fit
loss = self._train_model(input_fn=input_fn, hooks=hooks)
File "/Users/soalamro/tensorflow/lib/python2.7/site-packages/tensorflow/contrib/learn/python/learn/estimators/estimator.py", line 925, in _train_model
features, labels = input_fn()
File "runDNN.py", line 59, in <lambda>
regressor.fit(input_fn=lambda: input_fn(training_set), steps=5000)
File "runDNN.py", line 33, in input_fn
feature_cols = {k: tf.constant(data_set[k].values) for k in FEATURES}
File "runDNN.py", line 33, in <dictcomp>
feature_cols = {k: tf.constant(data_set[k].values) for k in FEATURES}
File "/Users/soalamro/tensorflow/lib/python2.7/site-packages/tensorflow/python/framework/constant_op.py", line 102, in constant
tensor_util.make_tensor_proto(value, dtype=dtype, shape=shape, verify_shape=verify_shape))
File "/Users/soalamro/tensorflow/lib/python2.7/site-packages/tensorflow/python/framework/tensor_util.py", line 454, in make_tensor_proto
append_fn(tensor_proto, proto_values)
File "/Users/soalamro/tensorflow/lib/python2.7/site-packages/tensorflow/python/framework/tensor_util.py", line 109, in SlowAppendObjectArrayToTensorProto
tensor_proto.string_val.extend([compat.as_bytes(x) for x in proto_values])
File "/Users/soalamro/tensorflow/lib/python2.7/site-packages/tensorflow/python/util/compat.py", line 65, in as_bytes
(bytes_or_text,))
TypeError: Expected binary or unicode string, got 2282667

代码处理数据这里,但不是我的数据.我的数据看起来像这样

The code worked with the data here, but not with my data. My data looks like this

5.7,106815586,139511807,2231,24740,2282667,18840355,171130880,1999831040,113770496,0.79580885,27402142,344196,87672
6.1,54026338,70549198,1429,11640,1154407,9527332,162021376,1995313152,115343360,0.4025088,80191390,205955,211776
6.3,77262946,100907828,2249,15430,1651081,13627045,175632384,2023624704,116916224,0.575645,56954782,256807,123040
4.0,32088162,41895065,1059,8370,685515,5657572,164495360,1952681984,111673344,0.23904419,102129566,127590,295039
4.4,58712162,76685611,1451,12530,1254661,10356080,167759872,1980440576,113770496,0.43741798,75505566,200913,217544

删除导致错误的数据行无济于事,因为代码显示了导致相同错误的另一行.我认为我的数据格式有问题.

Removing the line of data that causes the error does not help, because the code shows another line which causes the same error. I think the problem with the format of my data.

推荐答案

答案是加这个low_memory=False

这篇关于类型错误:预期的二进制或 unicode 字符串,得到 2282667的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆