0
我運行此代碼boston.py與不同的數據,但我不斷收到此錯誤。TypeError:預期的二進制或Unicode字符串,得到2282667
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
該代碼與數據here一起使用,但與我的數據無關。我的數據是這樣的
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
刪除導致該錯誤不利於數據線,因爲代碼顯示了另一種線,導致相同的錯誤。我認爲我的數據格式存在問題。
你的數據包含整數,它需要一個「binary或unicode string」 –