Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions official/resnet/resnet_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -424,6 +424,7 @@ def __init__(self, resnet_size, bottleneck, num_classes, num_filters,
self.block_strides = block_strides
self.final_size = final_size
self.dtype = dtype
self.pre_activation = resnet_version == 2

def _custom_dtype_getter(self, getter, name, shape=None, dtype=DEFAULT_DTYPE,
*args, **kwargs):
Expand Down Expand Up @@ -518,8 +519,11 @@ def __call__(self, inputs, training):
strides=self.block_strides[i], training=training,
name='block_layer{}'.format(i + 1), data_format=self.data_format)

inputs = batch_norm(inputs, training, self.data_format)
inputs = tf.nn.relu(inputs)
# Only apply the BN and ReLU for model that does pre_activation in each
# building/bottleneck block, eg resnet V2.
if self.pre_activation:
inputs = batch_norm(inputs, training, self.data_format)
inputs = tf.nn.relu(inputs)

# The current top layer has shape
# `batch_size x pool_size x pool_size x final_size`.
Expand Down