我正在从AI Adventures学习ML,但是该代码有问题
WARNING:tensorflow:From Ai1.py:12: load_csv_with_header (from tensorflow.contrib.learn.python.learn.datasets.base) is deprecated and will be removed in a future version. Instructions for updating: Use tf.data instead. Traceback (most recent call last): File "Ai1.py", line 12, in <module> target_dtype=np.int) File "C:\Users\Ardit\AppData\Local\Programs\Python\Python36\lib\site-packages\tensorflow\python\util\deprecation.py", line 324, in new_func return func(*args, **kwargs) File "C:\Users\Ardit\AppData\Local\Programs\Python\Python36\lib\site-packages\tensorflow\contrib\learn\python\learn\datasets\base.py", line 53, in load_csv_with_header header = next(data_file) File "C:\Users\Ardit\AppData\Local\Programs\Python\Python36\lib\site-packages\tensorflow\python\lib\io\file_io.py", line 220, in __next__ return self.next() File "C:\Users\Ardit\AppData\Local\Programs\Python\Python36\lib\site-packages\tensorflow\python\lib\io\file_io.py", line 214, in next retval = self.readline() File "C:\Users\Ardit\AppData\Local\Programs\Python\Python36\lib\site-packages\tensorflow\python\lib\io\file_io.py", line 184, in readline return self._prepare_value(self._read_buf.ReadLineAsString()) File "C:\Users\Ardit\AppData\Local\Programs\Python\Python36\lib\site-packages\tensorflow\python\lib\io\file_io.py", line 100, in _prepare_value return compat.as_str_any(val) File "C:\Users\Ardit\AppData\Local\Programs\Python\Python36\lib\site-packages\tensorflow\python\util\compat.py", line 107, in as_str_any return as_str(value) File "C:\Users\Ardit\AppData\Local\Programs\Python\Python36\lib\site-packages\tensorflow\python\util\compat.py", line 80, in as_text return bytes_or_text.decode(encoding) UnicodeDecodeError: 'utf-8' codec can't decode byte 0xff in position 8: invalid start byte
我正在使用python 3.6 谁能帮助我
答案 0 :(得分:0)
对不起,这是代码
import tensorflow as tf
import numpy as np
from tensorflow.contrib.learn.python.learn.datasets import base
# Data files
IRIS_TRAINING = "iris_training.csv"
IRIS_TEST = "iris_test.csv"
# Load datasets.
training_set = base.load_csv_with_header(filename=IRIS_TRAINING,
features_dtype=np.float32,
target_dtype=np.int)
test_set = base.load_csv_with_header(filename=IRIS_TEST,
features_dtype=np.float32,
target_dtype=np.int)
print(training_set.data)
print(training_set.target)
答案 1 :(得分:0)
不建议使用您使用的方法,请查看this link以了解如何导入数据。