
training_set = tf.contrib.learn.datasets.base.load_csv_with_header( filename=IRIS_TRAINING,target_dtype=np.int,features_dtype=np.float32)
我遇到了stopiteration错误.
当我检查API时,我没有找到任何关于load_csv_with_header()的信息.他们是否在最新版本中更改了它而没有更新教程?我怎样才能解决这个问题?
编辑:
我使用python3.6,如果这有任何区别.
if not os.path.exists(IRIS_TRAINING): raw = urllib.request.urlopen(IRIS_TRAINING_URL).read().decode() with open(IRIS_TRAINING,'w') as f: f.write(raw)if not os.path.exists(IRIS_TEST): raw = urllib.request.urlopen(IRIS_TEST_URL).read().decode() with open(IRIS_TEST,'w') as f: f.write(raw)
可能发生的是您的代码在IRIS_TRAINING之后创建了一个文件名.但文件是空的.因此提出了stopiteration.如果你看一下load_csv_with_header的实现:
with gfile.Open(filename) as csv_file: data_file = csv.reader(csv_file) header = next(data_file)
当next没有检测到任何其他要读取的项目时,会引发stopiteration,如文档https://docs.python.org/3.5/library/exceptions.html#StopIteration所示
请注意我的代码与Tensorflow教程中显示的Python 2版本相比的变化:
> urllib.request.urlopen而不是urllib.urlopen> read()在read()之后执行
总结以上是内存溢出为你收集整理的python -tf.contrib.learn load_csv_with_header在TensorFlow 1.1中不起作用全部内容,希望文章能够帮你解决python -tf.contrib.learn load_csv_with_header在TensorFlow 1.1中不起作用所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
微信扫一扫
支付宝扫一扫
评论列表(0条)