我使用不同的数据运行此代码boston.py,但我一直收到此错误。
unsigned char
copy_Nbits(unsigned char num_S, unsigned char num_D, char start_off, char end_off)
{
unsigned char u1 = 0;
unsigned char u2 = 0;
u1 = ~u1;
u1 = (u1 >> ((8 * sizeof(num_S)) - 1 - end_off + start_off));
u1 = (u1 << start_off);
u2 = u1;
u2 &= num_S;
u1 = ~u1;
u1 &= num_D;
return (u1 | u2);
}
代码使用数据here,但不使用我的数据。我的数据看起来像这样
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
删除导致错误的数据行没有帮助,因为代码显示另一行导致相同的错误。我认为我的数据格式存在问题。
答案 0 :(得分:0)
答案是添加此low_memory=False