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
"tests/L0/vscode:/vscode.git/clone" did not exist on "a651e2c24ecf97cbf367fd3f330df36760e1c597"
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
...
@@ -21,6 +21,7 @@ import os
import
shutil
import
shutil
import
gzip
import
gzip
import
numpy
as
np
import
numpy
as
np
from
six.moves
import
urllib
import
tensorflow
as
tf
import
tensorflow
as
tf
...
@@ -56,7 +57,7 @@ def check_labels_file_header(filename):
...
@@ -56,7 +57,7 @@ def check_labels_file_header(filename):
f
.
name
))
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."""
"""Download (and unzip) a file from the MNIST dataset, if it doesn't already exist."""
if
not
tf
.
gfile
.
Exists
(
directory
):
if
not
tf
.
gfile
.
Exists
(
directory
):
tf
.
gfile
.
MakeDirs
(
directory
)
tf
.
gfile
.
MakeDirs
(
directory
)
...
@@ -65,19 +66,18 @@ def maybe_download(directory, filename):
...
@@ -65,19 +66,18 @@ def maybe_download(directory, filename):
return
filepath
return
filepath
# CVDF mirror of http://yann.lecun.com/exdb/mnist/
# CVDF mirror of http://yann.lecun.com/exdb/mnist/
url
=
'https://storage.googleapis.com/cvdf-datasets/mnist/'
+
filename
+
'.gz'
url
=
'https://storage.googleapis.com/cvdf-datasets/mnist/'
+
filename
+
'.gz'
zipped_filename
=
filename
+
'.gz'
zipped_filepath
=
filepath
+
'.gz'
zipped_filepath
=
os
.
path
.
join
(
directory
,
zipped_filename
)
print
(
'Downloading %s to %s'
%
(
url
,
zipped_filepath
))
tf
.
contrib
.
learn
.
datasets
.
base
.
maybe_download
(
zipped_filename
,
directory
,
url
)
urllib
.
request
.
urlretrieve
(
url
,
zipped_filepath
)
with
gzip
.
open
(
os
.
path
.
join
(
zipped_filepath
),
'rb'
)
as
f_in
,
open
(
with
gzip
.
open
(
zipped_filepath
,
'rb'
)
as
f_in
,
open
(
filepath
,
'wb'
)
as
f_out
:
filepath
,
'wb'
)
as
f_out
:
shutil
.
copyfileobj
(
f_in
,
f_out
)
shutil
.
copyfileobj
(
f_in
,
f_out
)
os
.
remove
(
zipped_filepath
)
os
.
remove
(
zipped_filepath
)
return
filepath
return
filepath
def
dataset
(
directory
,
images_file
,
labels_file
):
def
dataset
(
directory
,
images_file
,
labels_file
):
images_file
=
maybe_
download
(
directory
,
images_file
)
images_file
=
download
(
directory
,
images_file
)
labels_file
=
maybe_
download
(
directory
,
labels_file
)
labels_file
=
download
(
directory
,
labels_file
)
check_image_file_header
(
images_file
)
check_image_file_header
(
images_file
)
check_labels_file_header
(
labels_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