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
b871670b
Commit
b871670b
authored
Sep 21, 2017
by
Neal Wu
Committed by
GitHub
Sep 21, 2017
Browse files
Latest changes to the official models (#2422)
parent
669422c2
Changes
6
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
15 additions
and
6 deletions
+15
-6
official/.gitignore
official/.gitignore
+0
-1
official/mnist/convert_to_records.py
official/mnist/convert_to_records.py
+6
-1
official/mnist/mnist.py
official/mnist/mnist.py
+1
-0
official/resnet/cifar10_download_and_extract.py
official/resnet/cifar10_download_and_extract.py
+2
-1
official/resnet/imagenet.py
official/resnet/imagenet.py
+3
-0
official/resnet/resnet_model.py
official/resnet/resnet_model.py
+3
-3
No files found.
official/.gitignore
View file @
b871670b
cnn/data
MNIST-data
MNIST-data
labels.txt
labels.txt
official/mnist/convert_to_records.py
View file @
b871670b
...
@@ -13,7 +13,12 @@
...
@@ -13,7 +13,12 @@
# limitations under the License.
# limitations under the License.
# ==============================================================================
# ==============================================================================
"""Converts MNIST data to TFRecords file format with Example protos."""
"""Converts MNIST data to TFRecords file format with Example protos.
To read about optimizations that can be applied to the input preprocessing
stage, see: https://www.tensorflow.org/performance/performance_guide#input_pipeline_optimization.
"""
from
__future__
import
absolute_import
from
__future__
import
absolute_import
from
__future__
import
division
from
__future__
import
division
from
__future__
import
print_function
from
__future__
import
print_function
...
...
official/mnist/mnist.py
View file @
b871670b
...
@@ -92,6 +92,7 @@ def mnist_model(inputs, mode):
...
@@ -92,6 +92,7 @@ def mnist_model(inputs, mode):
if
tf
.
test
.
is_built_with_cuda
():
if
tf
.
test
.
is_built_with_cuda
():
# When running on GPU, transpose the data from channels_last (NHWC) to
# When running on GPU, transpose the data from channels_last (NHWC) to
# channels_first (NCHW) to improve performance.
# channels_first (NCHW) to improve performance.
# See https://www.tensorflow.org/performance/performance_guide#data_formats
data_format
=
'channels_first'
data_format
=
'channels_first'
inputs
=
tf
.
transpose
(
inputs
,
[
0
,
3
,
1
,
2
])
inputs
=
tf
.
transpose
(
inputs
,
[
0
,
3
,
1
,
2
])
...
...
official/resnet/cifar10_download_and_extract.py
View file @
b871670b
...
@@ -13,7 +13,8 @@
...
@@ -13,7 +13,8 @@
# limitations under the License.
# limitations under the License.
# ==============================================================================
# ==============================================================================
"""Converts MNIST data to TFRecords file format with Example protos."""
"""Downloads and extracts the binary version of the CIFAR-10 dataset."""
from
__future__
import
absolute_import
from
__future__
import
absolute_import
from
__future__
import
division
from
__future__
import
division
from
__future__
import
print_function
from
__future__
import
print_function
...
...
official/resnet/imagenet.py
View file @
b871670b
...
@@ -27,6 +27,9 @@ For each synset, there are on average 150 images with bounding boxes."
...
@@ -27,6 +27,9 @@ For each synset, there are on average 150 images with bounding boxes."
WARNING: Don't use for object detection, in this case all the bounding boxes
WARNING: Don't use for object detection, in this case all the bounding boxes
of the image belong to just one class.
of the image belong to just one class.
To read about optimizations that can be applied to the input preprocessing
stage, see: https://www.tensorflow.org/performance/performance_guide#input_pipeline_optimization.
"""
"""
from
__future__
import
absolute_import
from
__future__
import
absolute_import
...
...
official/resnet/resnet_model.py
View file @
b871670b
...
@@ -41,6 +41,7 @@ _BATCH_NORM_EPSILON = 1e-5
...
@@ -41,6 +41,7 @@ _BATCH_NORM_EPSILON = 1e-5
def
batch_norm_relu
(
inputs
,
is_training
,
data_format
):
def
batch_norm_relu
(
inputs
,
is_training
,
data_format
):
"""Performs a batch normalization followed by a ReLU."""
"""Performs a batch normalization followed by a ReLU."""
# We set fused=True for a significant performance boost.
# We set fused=True for a significant performance boost.
# See https://www.tensorflow.org/performance/performance_guide#common_fused_ops
inputs
=
tf
.
layers
.
batch_normalization
(
inputs
=
tf
.
layers
.
batch_normalization
(
inputs
=
inputs
,
axis
=
1
if
data_format
==
'channels_first'
else
3
,
inputs
=
inputs
,
axis
=
1
if
data_format
==
'channels_first'
else
3
,
momentum
=
_BATCH_NORM_DECAY
,
epsilon
=
_BATCH_NORM_EPSILON
,
center
=
True
,
momentum
=
_BATCH_NORM_DECAY
,
epsilon
=
_BATCH_NORM_EPSILON
,
center
=
True
,
...
@@ -240,6 +241,7 @@ def cifar10_resnet_v2_generator(resnet_size, num_classes, data_format=None):
...
@@ -240,6 +241,7 @@ def cifar10_resnet_v2_generator(resnet_size, num_classes, data_format=None):
if
data_format
==
'channels_first'
:
if
data_format
==
'channels_first'
:
# Convert from channels_last (NHWC) to channels_first (NCHW). This
# Convert from channels_last (NHWC) to channels_first (NCHW). This
# provides a large performance boost on GPU.
# provides a large performance boost on GPU.
# See https://www.tensorflow.org/performance/performance_guide#data_formats
inputs
=
tf
.
transpose
(
inputs
,
[
0
,
3
,
1
,
2
])
inputs
=
tf
.
transpose
(
inputs
,
[
0
,
3
,
1
,
2
])
inputs
=
conv2d_fixed_padding
(
inputs
=
conv2d_fixed_padding
(
...
@@ -261,14 +263,12 @@ def cifar10_resnet_v2_generator(resnet_size, num_classes, data_format=None):
...
@@ -261,14 +263,12 @@ def cifar10_resnet_v2_generator(resnet_size, num_classes, data_format=None):
data_format
=
data_format
)
data_format
=
data_format
)
inputs
=
batch_norm_relu
(
inputs
,
is_training
,
data_format
)
inputs
=
batch_norm_relu
(
inputs
,
is_training
,
data_format
)
inputs
=
tf
.
layers
.
average_pooling2d
(
inputs
=
tf
.
layers
.
average_pooling2d
(
inputs
=
inputs
,
pool_size
=
8
,
strides
=
1
,
padding
=
'VALID'
,
inputs
=
inputs
,
pool_size
=
8
,
strides
=
1
,
padding
=
'VALID'
,
data_format
=
data_format
)
data_format
=
data_format
)
inputs
=
tf
.
identity
(
inputs
,
'final_avg_pool'
)
inputs
=
tf
.
identity
(
inputs
,
'final_avg_pool'
)
inputs
=
tf
.
reshape
(
inputs
,
[
-
1
,
64
])
inputs
=
tf
.
reshape
(
inputs
,
[
-
1
,
64
])
inputs
=
tf
.
layers
.
dense
(
inputs
=
tf
.
layers
.
dense
(
inputs
=
inputs
,
units
=
num_classes
)
inputs
=
inputs
,
units
=
num_classes
)
inputs
=
tf
.
identity
(
inputs
,
'final_dense'
)
inputs
=
tf
.
identity
(
inputs
,
'final_dense'
)
return
inputs
return
inputs
...
...
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