diff options
author | 2018-06-04 00:42:12 -0500 | |
---|---|---|
committer | 2018-06-03 22:42:12 -0700 | |
commit | 5d44932cda0e88537eb2526c7a420ee4ba320619 (patch) | |
tree | c1828ff5c1e24660e013ded2aa88b2a6a57cde79 /tensorflow/examples/learn | |
parent | a0fd55070bb83e369d1d73e777fc1ea9f1c3a6ae (diff) |
fix iris example to work with python3 (#19335)
iris.py did not work with python3 as urllib.urlopen is not in python3.
Switched to urlretrive from six. Same was done in:
tensorflow/examples/image_retraining/retrain.py
Diffstat (limited to 'tensorflow/examples/learn')
-rw-r--r-- | tensorflow/examples/learn/iris.py | 7 |
1 files changed, 3 insertions, 4 deletions
diff --git a/tensorflow/examples/learn/iris.py b/tensorflow/examples/learn/iris.py index 03e60972aa..86f5204ec3 100644 --- a/tensorflow/examples/learn/iris.py +++ b/tensorflow/examples/learn/iris.py @@ -21,7 +21,8 @@ from __future__ import division from __future__ import print_function import os -import urllib + +from six.moves.urllib.request import urlretrieve import tensorflow as tf @@ -38,9 +39,7 @@ FEATURE_KEYS = ['sepal_length', 'sepal_width', 'petal_length', 'petal_width'] def maybe_download_iris_data(file_name, download_url): """Downloads the file and returns the number of data.""" if not os.path.exists(file_name): - raw = urllib.urlopen(download_url).read() - with open(file_name, 'w') as f: - f.write(raw) + urlretrieve(download_url, file_name) # The first line is a comma-separated string. The first one is the number of # total data in the file. |