Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
ModelZoo
ResNet50_tensorflow
Commits
4a36e31b
Commit
4a36e31b
authored
Jan 02, 2018
by
Asim Shankar
Browse files
[mnist]: Incorporate comments in PR
parent
120526af
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
8 additions
and
8 deletions
+8
-8
official/mnist/dataset.py
official/mnist/dataset.py
+8
-8
No files found.
official/mnist/dataset.py
View file @
4a36e31b
...
...
@@ -21,6 +21,7 @@ import os
import
shutil
import
gzip
import
numpy
as
np
from
six.moves
import
urllib
import
tensorflow
as
tf
...
...
@@ -56,7 +57,7 @@ def check_labels_file_header(filename):
f
.
name
))
def
maybe_
download
(
directory
,
filename
):
def
download
(
directory
,
filename
):
"""Download (and unzip) a file from the MNIST dataset, if it doesn't already exist."""
if
not
tf
.
gfile
.
Exists
(
directory
):
tf
.
gfile
.
MakeDirs
(
directory
)
...
...
@@ -65,19 +66,18 @@ def maybe_download(directory, filename):
return
filepath
# CVDF mirror of http://yann.lecun.com/exdb/mnist/
url
=
'https://storage.googleapis.com/cvdf-datasets/mnist/'
+
filename
+
'.gz'
zipped_filename
=
filename
+
'.gz'
zipped_filepath
=
os
.
path
.
join
(
directory
,
zipped_filename
)
tf
.
contrib
.
learn
.
datasets
.
base
.
maybe_download
(
zipped_filename
,
directory
,
url
)
with
gzip
.
open
(
os
.
path
.
join
(
zipped_filepath
),
'rb'
)
as
f_in
,
open
(
filepath
,
'wb'
)
as
f_out
:
zipped_filepath
=
filepath
+
'.gz'
print
(
'Downloading %s to %s'
%
(
url
,
zipped_filepath
))
urllib
.
request
.
urlretrieve
(
url
,
zipped_filepath
)
with
gzip
.
open
(
zipped_filepath
,
'rb'
)
as
f_in
,
open
(
filepath
,
'wb'
)
as
f_out
:
shutil
.
copyfileobj
(
f_in
,
f_out
)
os
.
remove
(
zipped_filepath
)
return
filepath
def
dataset
(
directory
,
images_file
,
labels_file
):
images_file
=
maybe_
download
(
directory
,
images_file
)
labels_file
=
maybe_
download
(
directory
,
labels_file
)
images_file
=
download
(
directory
,
images_file
)
labels_file
=
download
(
directory
,
labels_file
)
check_image_file_header
(
images_file
)
check_labels_file_header
(
labels_file
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment