Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
bob.learn.tensorflow
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
This is an archived project. Repository and other project resources are read-only.
Show more breadcrumbs
bob
bob.learn.tensorflow
Commits
6809b360
Commit
6809b360
authored
6 years ago
by
Amir MOHAMMADI
Browse files
Options
Downloads
Patches
Plain Diff
Fixes in inception architectures
parent
316eca76
No related branches found
No related tags found
1 merge request
!75
A lot of new features
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
bob/learn/tensorflow/network/InceptionResnetV1.py
+63
-78
63 additions, 78 deletions
bob/learn/tensorflow/network/InceptionResnetV1.py
bob/learn/tensorflow/network/InceptionResnetV2.py
+0
-1
0 additions, 1 deletion
bob/learn/tensorflow/network/InceptionResnetV2.py
with
63 additions
and
79 deletions
bob/learn/tensorflow/network/InceptionResnetV1.py
+
63
−
78
View file @
6809b360
...
@@ -32,10 +32,9 @@ def block35(net,
...
@@ -32,10 +32,9 @@ def block35(net,
scale
=
1.0
,
scale
=
1.0
,
activation_fn
=
tf
.
nn
.
relu
,
activation_fn
=
tf
.
nn
.
relu
,
scope
=
None
,
scope
=
None
,
reuse
=
None
,
trainable_variables
=
True
):
trainable_variables
=
True
):
"""
Builds the 35x35 resnet block.
"""
"""
Builds the 35x35 resnet block.
"""
with
tf
.
variable_scope
(
scope
,
'
Block35
'
,
[
net
]
,
reuse
=
reuse
):
with
tf
.
variable_scope
(
scope
,
'
Block35
'
,
[
net
]):
with
tf
.
variable_scope
(
'
Branch_0
'
):
with
tf
.
variable_scope
(
'
Branch_0
'
):
tower_conv
=
slim
.
conv2d
(
tower_conv
=
slim
.
conv2d
(
net
,
32
,
1
,
scope
=
'
Conv2d_1x1
'
,
trainable
=
trainable_variables
)
net
,
32
,
1
,
scope
=
'
Conv2d_1x1
'
,
trainable
=
trainable_variables
)
...
@@ -91,10 +90,9 @@ def block17(net,
...
@@ -91,10 +90,9 @@ def block17(net,
scale
=
1.0
,
scale
=
1.0
,
activation_fn
=
tf
.
nn
.
relu
,
activation_fn
=
tf
.
nn
.
relu
,
scope
=
None
,
scope
=
None
,
reuse
=
None
,
trainable_variables
=
True
):
trainable_variables
=
True
):
"""
Builds the 17x17 resnet block.
"""
"""
Builds the 17x17 resnet block.
"""
with
tf
.
variable_scope
(
scope
,
'
Block17
'
,
[
net
]
,
reuse
=
reuse
):
with
tf
.
variable_scope
(
scope
,
'
Block17
'
,
[
net
]):
with
tf
.
variable_scope
(
'
Branch_0
'
):
with
tf
.
variable_scope
(
'
Branch_0
'
):
tower_conv
=
slim
.
conv2d
(
tower_conv
=
slim
.
conv2d
(
net
,
128
,
1
,
scope
=
'
Conv2d_1x1
'
,
trainable
=
trainable_variables
)
net
,
128
,
1
,
scope
=
'
Conv2d_1x1
'
,
trainable
=
trainable_variables
)
...
@@ -135,10 +133,9 @@ def block8(net,
...
@@ -135,10 +133,9 @@ def block8(net,
scale
=
1.0
,
scale
=
1.0
,
activation_fn
=
tf
.
nn
.
relu
,
activation_fn
=
tf
.
nn
.
relu
,
scope
=
None
,
scope
=
None
,
reuse
=
None
,
trainable_variables
=
True
):
trainable_variables
=
True
):
"""
Builds the 8x8 resnet block.
"""
"""
Builds the 8x8 resnet block.
"""
with
tf
.
variable_scope
(
scope
,
'
Block8
'
,
[
net
]
,
reuse
=
reuse
):
with
tf
.
variable_scope
(
scope
,
'
Block8
'
,
[
net
]):
with
tf
.
variable_scope
(
'
Branch_0
'
):
with
tf
.
variable_scope
(
'
Branch_0
'
):
tower_conv
=
slim
.
conv2d
(
tower_conv
=
slim
.
conv2d
(
net
,
192
,
1
,
scope
=
'
Conv2d_1x1
'
,
trainable
=
trainable_variables
)
net
,
192
,
1
,
scope
=
'
Conv2d_1x1
'
,
trainable
=
trainable_variables
)
...
@@ -174,8 +171,8 @@ def block8(net,
...
@@ -174,8 +171,8 @@ def block8(net,
return
net
return
net
def
reduction_a
(
net
,
k
,
l
,
m
,
n
,
trainable_variables
=
True
,
reuse
=
None
):
def
reduction_a
(
net
,
k
,
l
,
m
,
n
,
trainable_variables
=
True
):
with
tf
.
variable_scope
(
'
Branch_0
'
,
reuse
=
reuse
):
with
tf
.
variable_scope
(
'
Branch_0
'
):
tower_conv
=
slim
.
conv2d
(
tower_conv
=
slim
.
conv2d
(
net
,
net
,
n
,
n
,
...
@@ -184,7 +181,7 @@ def reduction_a(net, k, l, m, n, trainable_variables=True, reuse=None):
...
@@ -184,7 +181,7 @@ def reduction_a(net, k, l, m, n, trainable_variables=True, reuse=None):
padding
=
'
VALID
'
,
padding
=
'
VALID
'
,
scope
=
'
Conv2d_1a_3x3
'
,
scope
=
'
Conv2d_1a_3x3
'
,
trainable
=
trainable_variables
)
trainable
=
trainable_variables
)
with
tf
.
variable_scope
(
'
Branch_1
'
,
reuse
=
reuse
):
with
tf
.
variable_scope
(
'
Branch_1
'
):
tower_conv1_0
=
slim
.
conv2d
(
tower_conv1_0
=
slim
.
conv2d
(
net
,
k
,
1
,
scope
=
'
Conv2d_0a_1x1
'
,
trainable
=
trainable_variables
)
net
,
k
,
1
,
scope
=
'
Conv2d_0a_1x1
'
,
trainable
=
trainable_variables
)
tower_conv1_1
=
slim
.
conv2d
(
tower_conv1_1
=
slim
.
conv2d
(
...
@@ -201,15 +198,15 @@ def reduction_a(net, k, l, m, n, trainable_variables=True, reuse=None):
...
@@ -201,15 +198,15 @@ def reduction_a(net, k, l, m, n, trainable_variables=True, reuse=None):
padding
=
'
VALID
'
,
padding
=
'
VALID
'
,
scope
=
'
Conv2d_1a_3x3
'
,
scope
=
'
Conv2d_1a_3x3
'
,
trainable
=
trainable_variables
)
trainable
=
trainable_variables
)
with
tf
.
variable_scope
(
'
Branch_2
'
,
reuse
=
reuse
):
with
tf
.
variable_scope
(
'
Branch_2
'
):
tower_pool
=
slim
.
max_pool2d
(
tower_pool
=
slim
.
max_pool2d
(
net
,
3
,
stride
=
2
,
padding
=
'
VALID
'
,
scope
=
'
MaxPool_1a_3x3
'
)
net
,
3
,
stride
=
2
,
padding
=
'
VALID
'
,
scope
=
'
MaxPool_1a_3x3
'
)
net
=
tf
.
concat
([
tower_conv
,
tower_conv1_2
,
tower_pool
],
3
)
net
=
tf
.
concat
([
tower_conv
,
tower_conv1_2
,
tower_pool
],
3
)
return
net
return
net
def
reduction_b
(
net
,
reuse
=
None
,
trainable_variables
=
True
):
def
reduction_b
(
net
,
trainable_variables
=
True
):
with
tf
.
variable_scope
(
'
Branch_0
'
,
reuse
=
reuse
):
with
tf
.
variable_scope
(
'
Branch_0
'
):
tower_conv
=
slim
.
conv2d
(
tower_conv
=
slim
.
conv2d
(
net
,
256
,
1
,
scope
=
'
Conv2d_0a_1x1
'
,
trainable
=
trainable_variables
)
net
,
256
,
1
,
scope
=
'
Conv2d_0a_1x1
'
,
trainable
=
trainable_variables
)
tower_conv_1
=
slim
.
conv2d
(
tower_conv_1
=
slim
.
conv2d
(
...
@@ -220,7 +217,7 @@ def reduction_b(net, reuse=None, trainable_variables=True):
...
@@ -220,7 +217,7 @@ def reduction_b(net, reuse=None, trainable_variables=True):
padding
=
'
VALID
'
,
padding
=
'
VALID
'
,
scope
=
'
Conv2d_1a_3x3
'
,
scope
=
'
Conv2d_1a_3x3
'
,
trainable
=
trainable_variables
)
trainable
=
trainable_variables
)
with
tf
.
variable_scope
(
'
Branch_1
'
,
reuse
=
reuse
):
with
tf
.
variable_scope
(
'
Branch_1
'
):
tower_conv1
=
slim
.
conv2d
(
tower_conv1
=
slim
.
conv2d
(
net
,
256
,
1
,
scope
=
'
Conv2d_0a_1x1
'
,
trainable
=
trainable_variables
)
net
,
256
,
1
,
scope
=
'
Conv2d_0a_1x1
'
,
trainable
=
trainable_variables
)
tower_conv1_1
=
slim
.
conv2d
(
tower_conv1_1
=
slim
.
conv2d
(
...
@@ -231,7 +228,7 @@ def reduction_b(net, reuse=None, trainable_variables=True):
...
@@ -231,7 +228,7 @@ def reduction_b(net, reuse=None, trainable_variables=True):
padding
=
'
VALID
'
,
padding
=
'
VALID
'
,
scope
=
'
Conv2d_1a_3x3
'
,
scope
=
'
Conv2d_1a_3x3
'
,
trainable
=
trainable_variables
)
trainable
=
trainable_variables
)
with
tf
.
variable_scope
(
'
Branch_2
'
,
reuse
=
reuse
):
with
tf
.
variable_scope
(
'
Branch_2
'
):
tower_conv2
=
slim
.
conv2d
(
tower_conv2
=
slim
.
conv2d
(
net
,
256
,
1
,
scope
=
'
Conv2d_0a_1x1
'
,
trainable
=
trainable_variables
)
net
,
256
,
1
,
scope
=
'
Conv2d_0a_1x1
'
,
trainable
=
trainable_variables
)
tower_conv2_1
=
slim
.
conv2d
(
tower_conv2_1
=
slim
.
conv2d
(
...
@@ -248,7 +245,7 @@ def reduction_b(net, reuse=None, trainable_variables=True):
...
@@ -248,7 +245,7 @@ def reduction_b(net, reuse=None, trainable_variables=True):
padding
=
'
VALID
'
,
padding
=
'
VALID
'
,
scope
=
'
Conv2d_1a_3x3
'
,
scope
=
'
Conv2d_1a_3x3
'
,
trainable
=
trainable_variables
)
trainable
=
trainable_variables
)
with
tf
.
variable_scope
(
'
Branch_3
'
,
reuse
=
reuse
):
with
tf
.
variable_scope
(
'
Branch_3
'
):
tower_pool
=
slim
.
max_pool2d
(
tower_pool
=
slim
.
max_pool2d
(
net
,
3
,
stride
=
2
,
padding
=
'
VALID
'
,
scope
=
'
MaxPool_1a_3x3
'
)
net
,
3
,
stride
=
2
,
padding
=
'
VALID
'
,
scope
=
'
MaxPool_1a_3x3
'
)
net
=
tf
.
concat
([
tower_conv_1
,
tower_conv1_1
,
tower_conv2_2
,
tower_pool
],
net
=
tf
.
concat
([
tower_conv_1
,
tower_conv1_1
,
tower_conv2_2
,
tower_pool
],
...
@@ -266,7 +263,7 @@ def inception_resnet_v1_batch_norm(inputs,
...
@@ -266,7 +263,7 @@ def inception_resnet_v1_batch_norm(inputs,
weight_decay
=
1e-5
,
weight_decay
=
1e-5
,
**
kwargs
):
**
kwargs
):
"""
"""
Creates the Inception Resnet V1 model applying batch not to each
Creates the Inception Resnet V1 model applying batch not to each
Convolutional and FullyConnected layer.
Convolutional and FullyConnected layer.
Parameters
Parameters
...
@@ -274,20 +271,20 @@ def inception_resnet_v1_batch_norm(inputs,
...
@@ -274,20 +271,20 @@ def inception_resnet_v1_batch_norm(inputs,
inputs:
inputs:
4-D tensor of size [batch_size, height, width, 3].
4-D tensor of size [batch_size, height, width, 3].
num_classes:
num_classes:
number of predicted classes.
number of predicted classes.
is_training:
is_training:
whether is training or not.
whether is training or not.
dropout_keep_prob: float
dropout_keep_prob: float
the fraction to keep before final layer.
the fraction to keep before final layer.
reuse:
reuse:
whether or not the network and its variables should be reused. To be
whether or not the network and its variables should be reused. To be
able to reuse
'
scope
'
must be given.
able to reuse
'
scope
'
must be given.
scope:
scope:
Optional variable_scope.
Optional variable_scope.
...
@@ -321,10 +318,10 @@ def inception_resnet_v1_batch_norm(inputs,
...
@@ -321,10 +318,10 @@ def inception_resnet_v1_batch_norm(inputs,
normalizer_params
=
batch_norm_params
):
normalizer_params
=
batch_norm_params
):
return
inception_resnet_v1
(
return
inception_resnet_v1
(
inputs
,
inputs
,
dropout_keep_prob
=
0.8
,
dropout_keep_prob
=
dropout_keep_prob
,
bottleneck_layer_size
=
128
,
bottleneck_layer_size
=
bottleneck_layer_size
,
Tiago de Freitas Pereira
@tiago.pereira
·
Apr 23, 2019
Owner
thanks for fixing this
thanks for fixing this
Please
register
or
sign in
to reply
reuse
=
Non
e
,
reuse
=
reus
e
,
scope
=
'
InceptionResnetV1
'
,
scope
=
scope
,
mode
=
mode
,
mode
=
mode
,
trainable_variables
=
trainable_variables
,
trainable_variables
=
trainable_variables
,
)
)
...
@@ -346,20 +343,20 @@ def inception_resnet_v1(inputs,
...
@@ -346,20 +343,20 @@ def inception_resnet_v1(inputs,
inputs:
inputs:
4-D tensor of size [batch_size, height, width, 3].
4-D tensor of size [batch_size, height, width, 3].
num_classes:
num_classes:
number of predicted classes.
number of predicted classes.
is_training:
is_training:
whether is training or not.
whether is training or not.
dropout_keep_prob: float
dropout_keep_prob: float
the fraction to keep before final layer.
the fraction to keep before final layer.
reuse:
reuse:
whether or not the network and its variables should be reused. To be
whether or not the network and its variables should be reused. To be
able to reuse
'
scope
'
must be given.
able to reuse
'
scope
'
must be given.
scope:
scope:
Optional variable_scope.
Optional variable_scope.
...
@@ -393,7 +390,7 @@ def inception_resnet_v1(inputs,
...
@@ -393,7 +390,7 @@ def inception_resnet_v1(inputs,
with
slim
.
arg_scope
(
with
slim
.
arg_scope
(
[
slim
.
batch_norm
],
[
slim
.
batch_norm
],
is_training
=
(
mode
==
tf
.
estimator
.
ModeKeys
.
TRAIN
),
is_training
=
(
mode
==
tf
.
estimator
.
ModeKeys
.
TRAIN
),
trainable
=
trainable
):
trainable
=
trainable
):
name
=
"
Conv2d_1a_3x3
"
name
=
"
Conv2d_1a_3x3
"
trainable
=
is_trainable
(
name
,
trainable_variables
,
mode
=
mode
)
trainable
=
is_trainable
(
name
,
trainable_variables
,
mode
=
mode
)
...
@@ -404,8 +401,7 @@ def inception_resnet_v1(inputs,
...
@@ -404,8 +401,7 @@ def inception_resnet_v1(inputs,
stride
=
2
,
stride
=
2
,
padding
=
'
VALID
'
,
padding
=
'
VALID
'
,
scope
=
name
,
scope
=
name
,
trainable
=
trainable
,
trainable
=
trainable
)
reuse
=
reuse
)
end_points
[
name
]
=
net
end_points
[
name
]
=
net
# 147 x 147 x 32
# 147 x 147 x 32
...
@@ -414,7 +410,7 @@ def inception_resnet_v1(inputs,
...
@@ -414,7 +410,7 @@ def inception_resnet_v1(inputs,
with
slim
.
arg_scope
(
with
slim
.
arg_scope
(
[
slim
.
batch_norm
],
[
slim
.
batch_norm
],
is_training
=
(
mode
==
tf
.
estimator
.
ModeKeys
.
TRAIN
),
is_training
=
(
mode
==
tf
.
estimator
.
ModeKeys
.
TRAIN
),
trainable
=
trainable
):
trainable
=
trainable
):
name
=
"
Conv2d_2a_3x3
"
name
=
"
Conv2d_2a_3x3
"
trainable
=
is_trainable
(
name
,
trainable_variables
,
mode
=
mode
)
trainable
=
is_trainable
(
name
,
trainable_variables
,
mode
=
mode
)
net
=
slim
.
conv2d
(
net
=
slim
.
conv2d
(
...
@@ -423,8 +419,7 @@ def inception_resnet_v1(inputs,
...
@@ -423,8 +419,7 @@ def inception_resnet_v1(inputs,
3
,
3
,
padding
=
'
VALID
'
,
padding
=
'
VALID
'
,
scope
=
name
,
scope
=
name
,
trainable
=
trainable
,
trainable
=
trainable
)
reuse
=
reuse
)
end_points
[
name
]
=
net
end_points
[
name
]
=
net
# 147 x 147 x 64
# 147 x 147 x 64
...
@@ -433,12 +428,12 @@ def inception_resnet_v1(inputs,
...
@@ -433,12 +428,12 @@ def inception_resnet_v1(inputs,
with
slim
.
arg_scope
(
with
slim
.
arg_scope
(
[
slim
.
batch_norm
],
[
slim
.
batch_norm
],
is_training
=
(
mode
==
tf
.
estimator
.
ModeKeys
.
TRAIN
),
is_training
=
(
mode
==
tf
.
estimator
.
ModeKeys
.
TRAIN
),
trainable
=
trainable
):
trainable
=
trainable
):
name
=
"
Conv2d_2b_3x3
"
name
=
"
Conv2d_2b_3x3
"
trainable
=
is_trainable
(
name
,
trainable_variables
,
mode
=
mode
)
trainable
=
is_trainable
(
name
,
trainable_variables
,
mode
=
mode
)
net
=
slim
.
conv2d
(
net
=
slim
.
conv2d
(
net
,
64
,
3
,
scope
=
name
,
trainable
=
trainable
,
reuse
=
reuse
)
net
,
64
,
3
,
scope
=
name
,
trainable
=
trainable
)
end_points
[
name
]
=
net
end_points
[
name
]
=
net
# 73 x 73 x 64
# 73 x 73 x 64
...
@@ -452,18 +447,17 @@ def inception_resnet_v1(inputs,
...
@@ -452,18 +447,17 @@ def inception_resnet_v1(inputs,
with
slim
.
arg_scope
(
with
slim
.
arg_scope
(
[
slim
.
batch_norm
],
[
slim
.
batch_norm
],
is_training
=
(
mode
==
tf
.
estimator
.
ModeKeys
.
TRAIN
),
is_training
=
(
mode
==
tf
.
estimator
.
ModeKeys
.
TRAIN
),
trainable
=
trainable
):
trainable
=
trainable
):
name
=
"
Conv2d_3b_1x1
"
name
=
"
Conv2d_3b_1x1
"
trainable
=
is_trainable
(
name
,
trainable_variables
,
mode
=
mode
)
trainable
=
is_trainable
(
name
,
trainable_variables
,
mode
=
mode
)
net
=
slim
.
conv2d
(
net
=
slim
.
conv2d
(
net
,
net
,
80
,
80
,
1
,
1
,
padding
=
'
VALID
'
,
padding
=
'
VALID
'
,
scope
=
name
,
scope
=
name
,
trainable
=
trainable
,
trainable
=
trainable
)
reuse
=
reuse
)
end_points
[
name
]
=
net
end_points
[
name
]
=
net
# 71 x 71 x 192
# 71 x 71 x 192
...
@@ -472,7 +466,7 @@ def inception_resnet_v1(inputs,
...
@@ -472,7 +466,7 @@ def inception_resnet_v1(inputs,
with
slim
.
arg_scope
(
with
slim
.
arg_scope
(
[
slim
.
batch_norm
],
[
slim
.
batch_norm
],
is_training
=
(
mode
==
tf
.
estimator
.
ModeKeys
.
TRAIN
),
is_training
=
(
mode
==
tf
.
estimator
.
ModeKeys
.
TRAIN
),
trainable
=
trainable
):
trainable
=
trainable
):
name
=
"
Conv2d_4a_3x3
"
name
=
"
Conv2d_4a_3x3
"
trainable
=
is_trainable
(
name
,
trainable_variables
,
mode
=
mode
)
trainable
=
is_trainable
(
name
,
trainable_variables
,
mode
=
mode
)
...
@@ -482,8 +476,7 @@ def inception_resnet_v1(inputs,
...
@@ -482,8 +476,7 @@ def inception_resnet_v1(inputs,
3
,
3
,
padding
=
'
VALID
'
,
padding
=
'
VALID
'
,
scope
=
name
,
scope
=
name
,
trainable
=
trainable
,
trainable
=
trainable
)
reuse
=
reuse
)
end_points
[
name
]
=
net
end_points
[
name
]
=
net
# 35 x 35 x 256
# 35 x 35 x 256
...
@@ -492,10 +485,10 @@ def inception_resnet_v1(inputs,
...
@@ -492,10 +485,10 @@ def inception_resnet_v1(inputs,
with
slim
.
arg_scope
(
with
slim
.
arg_scope
(
[
slim
.
batch_norm
],
[
slim
.
batch_norm
],
is_training
=
(
mode
==
tf
.
estimator
.
ModeKeys
.
TRAIN
),
is_training
=
(
mode
==
tf
.
estimator
.
ModeKeys
.
TRAIN
),
trainable
=
trainable
):
trainable
=
trainable
):
name
=
"
Conv2d_4b_3x3
"
name
=
"
Conv2d_4b_3x3
"
trainable
=
is_trainable
(
name
,
trainable_variables
,
mode
=
mode
)
trainable
=
is_trainable
(
name
,
trainable_variables
,
mode
=
mode
)
net
=
slim
.
conv2d
(
net
=
slim
.
conv2d
(
net
,
net
,
256
,
256
,
...
@@ -503,8 +496,7 @@ def inception_resnet_v1(inputs,
...
@@ -503,8 +496,7 @@ def inception_resnet_v1(inputs,
stride
=
2
,
stride
=
2
,
padding
=
'
VALID
'
,
padding
=
'
VALID
'
,
scope
=
name
,
scope
=
name
,
trainable
=
trainable
,
trainable
=
trainable
)
reuse
=
reuse
)
end_points
[
name
]
=
net
end_points
[
name
]
=
net
# 5 x Inception-resnet-A
# 5 x Inception-resnet-A
...
@@ -513,7 +505,7 @@ def inception_resnet_v1(inputs,
...
@@ -513,7 +505,7 @@ def inception_resnet_v1(inputs,
with
slim
.
arg_scope
(
with
slim
.
arg_scope
(
[
slim
.
batch_norm
],
[
slim
.
batch_norm
],
is_training
=
(
mode
==
tf
.
estimator
.
ModeKeys
.
TRAIN
),
is_training
=
(
mode
==
tf
.
estimator
.
ModeKeys
.
TRAIN
),
trainable
=
trainable
):
trainable
=
trainable
):
name
=
"
block35
"
name
=
"
block35
"
trainable
=
is_trainable
(
name
,
trainable_variables
,
mode
=
mode
)
trainable
=
is_trainable
(
name
,
trainable_variables
,
mode
=
mode
)
...
@@ -522,8 +514,7 @@ def inception_resnet_v1(inputs,
...
@@ -522,8 +514,7 @@ def inception_resnet_v1(inputs,
5
,
5
,
block35
,
block35
,
scale
=
0.17
,
scale
=
0.17
,
trainable_variables
=
trainable
,
trainable_variables
=
trainable
)
reuse
=
reuse
)
end_points
[
name
]
=
net
end_points
[
name
]
=
net
# Reduction-A
# Reduction-A
...
@@ -532,8 +523,8 @@ def inception_resnet_v1(inputs,
...
@@ -532,8 +523,8 @@ def inception_resnet_v1(inputs,
with
slim
.
arg_scope
(
with
slim
.
arg_scope
(
[
slim
.
batch_norm
],
[
slim
.
batch_norm
],
is_training
=
(
mode
==
tf
.
estimator
.
ModeKeys
.
TRAIN
),
is_training
=
(
mode
==
tf
.
estimator
.
ModeKeys
.
TRAIN
),
trainable
=
trainable
):
trainable
=
trainable
):
name
=
"
Mixed_6a
"
name
=
"
Mixed_6a
"
trainable
=
is_trainable
(
name
,
trainable_variables
,
mode
=
mode
)
trainable
=
is_trainable
(
name
,
trainable_variables
,
mode
=
mode
)
with
tf
.
variable_scope
(
name
):
with
tf
.
variable_scope
(
name
):
...
@@ -543,8 +534,7 @@ def inception_resnet_v1(inputs,
...
@@ -543,8 +534,7 @@ def inception_resnet_v1(inputs,
192
,
192
,
256
,
256
,
384
,
384
,
trainable_variables
=
trainable
,
trainable_variables
=
trainable
)
reuse
=
reuse
)
end_points
[
name
]
=
net
end_points
[
name
]
=
net
# 10 x Inception-Resnet-B
# 10 x Inception-Resnet-B
...
@@ -553,17 +543,16 @@ def inception_resnet_v1(inputs,
...
@@ -553,17 +543,16 @@ def inception_resnet_v1(inputs,
with
slim
.
arg_scope
(
with
slim
.
arg_scope
(
[
slim
.
batch_norm
],
[
slim
.
batch_norm
],
is_training
=
(
mode
==
tf
.
estimator
.
ModeKeys
.
TRAIN
),
is_training
=
(
mode
==
tf
.
estimator
.
ModeKeys
.
TRAIN
),
trainable
=
trainable
):
trainable
=
trainable
):
name
=
"
block17
"
name
=
"
block17
"
trainable
=
is_trainable
(
name
,
trainable_variables
,
mode
=
mode
)
trainable
=
is_trainable
(
name
,
trainable_variables
,
mode
=
mode
)
net
=
slim
.
repeat
(
net
=
slim
.
repeat
(
net
,
net
,
10
,
10
,
block17
,
block17
,
scale
=
0.10
,
scale
=
0.10
,
trainable_variables
=
trainable
,
trainable_variables
=
trainable
)
reuse
=
reuse
)
end_points
[
name
]
=
net
end_points
[
name
]
=
net
# Reduction-B
# Reduction-B
...
@@ -572,14 +561,14 @@ def inception_resnet_v1(inputs,
...
@@ -572,14 +561,14 @@ def inception_resnet_v1(inputs,
with
slim
.
arg_scope
(
with
slim
.
arg_scope
(
[
slim
.
batch_norm
],
[
slim
.
batch_norm
],
is_training
=
(
mode
==
tf
.
estimator
.
ModeKeys
.
TRAIN
),
is_training
=
(
mode
==
tf
.
estimator
.
ModeKeys
.
TRAIN
),
trainable
=
trainable
):
trainable
=
trainable
):
name
=
"
Mixed_7a
"
name
=
"
Mixed_7a
"
trainable
=
is_trainable
(
name
,
trainable_variables
,
mode
=
mode
)
trainable
=
is_trainable
(
name
,
trainable_variables
,
mode
=
mode
)
with
tf
.
variable_scope
(
name
):
with
tf
.
variable_scope
(
name
):
net
=
reduction_b
(
net
=
reduction_b
(
net
,
trainable_variables
=
trainable
,
reuse
=
reuse
)
net
,
trainable_variables
=
trainable
)
end_points
[
name
]
=
net
end_points
[
name
]
=
net
# 5 x Inception-Resnet-C
# 5 x Inception-Resnet-C
...
@@ -588,8 +577,8 @@ def inception_resnet_v1(inputs,
...
@@ -588,8 +577,8 @@ def inception_resnet_v1(inputs,
with
slim
.
arg_scope
(
with
slim
.
arg_scope
(
[
slim
.
batch_norm
],
[
slim
.
batch_norm
],
is_training
=
(
mode
==
tf
.
estimator
.
ModeKeys
.
TRAIN
),
is_training
=
(
mode
==
tf
.
estimator
.
ModeKeys
.
TRAIN
),
trainable
=
trainable
):
trainable
=
trainable
):
name
=
"
block8
"
name
=
"
block8
"
trainable
=
is_trainable
(
name
,
trainable_variables
,
mode
=
mode
)
trainable
=
is_trainable
(
name
,
trainable_variables
,
mode
=
mode
)
net
=
slim
.
repeat
(
net
=
slim
.
repeat
(
...
@@ -597,27 +586,24 @@ def inception_resnet_v1(inputs,
...
@@ -597,27 +586,24 @@ def inception_resnet_v1(inputs,
5
,
5
,
block8
,
block8
,
scale
=
0.20
,
scale
=
0.20
,
trainable_variables
=
trainable
,
trainable_variables
=
trainable
)
reuse
=
reuse
)
end_points
[
name
]
=
net
end_points
[
name
]
=
net
name
=
"
Mixed_8b_BN
"
name
=
"
Mixed_8b_BN
"
trainable
=
is_trainable
(
name
,
trainable_variables
,
mode
=
mode
)
trainable
=
is_trainable
(
name
,
trainable_variables
,
mode
=
mode
)
with
slim
.
arg_scope
(
with
slim
.
arg_scope
(
[
slim
.
batch_norm
],
[
slim
.
batch_norm
],
is_training
=
(
mode
==
tf
.
estimator
.
ModeKeys
.
TRAIN
),
is_training
=
(
mode
==
tf
.
estimator
.
ModeKeys
.
TRAIN
),
trainable
=
trainable
):
trainable
=
trainable
):
name
=
"
Mixed_8b
"
name
=
"
Mixed_8b
"
trainable
=
is_trainable
(
name
,
trainable_variables
,
mode
=
mode
)
trainable
=
is_trainable
(
name
,
trainable_variables
,
mode
=
mode
)
net
=
block8
(
net
=
block8
(
net
,
net
,
activation_fn
=
None
,
activation_fn
=
None
,
trainable_variables
=
trainable
,
trainable_variables
=
trainable
)
reuse
=
reuse
)
end_points
[
name
]
=
net
end_points
[
name
]
=
net
with
tf
.
variable_scope
(
'
Logits
'
):
with
tf
.
variable_scope
(
'
Logits
'
):
end_points
[
'
PrePool
'
]
=
net
end_points
[
'
PrePool
'
]
=
net
#pylint: disable=no-member
#pylint: disable=no-member
...
@@ -641,8 +627,8 @@ def inception_resnet_v1(inputs,
...
@@ -641,8 +627,8 @@ def inception_resnet_v1(inputs,
with
slim
.
arg_scope
(
with
slim
.
arg_scope
(
[
slim
.
batch_norm
],
[
slim
.
batch_norm
],
is_training
=
(
mode
==
tf
.
estimator
.
ModeKeys
.
TRAIN
),
is_training
=
(
mode
==
tf
.
estimator
.
ModeKeys
.
TRAIN
),
trainable
=
trainable
):
trainable
=
trainable
):
name
=
"
Bottleneck
"
name
=
"
Bottleneck
"
trainable
=
is_trainable
(
name
,
trainable_variables
,
mode
=
mode
)
trainable
=
is_trainable
(
name
,
trainable_variables
,
mode
=
mode
)
net
=
slim
.
fully_connected
(
net
=
slim
.
fully_connected
(
...
@@ -650,7 +636,6 @@ def inception_resnet_v1(inputs,
...
@@ -650,7 +636,6 @@ def inception_resnet_v1(inputs,
bottleneck_layer_size
,
bottleneck_layer_size
,
activation_fn
=
None
,
activation_fn
=
None
,
scope
=
name
,
scope
=
name
,
reuse
=
reuse
,
trainable
=
trainable
)
trainable
=
trainable
)
end_points
[
name
]
=
net
end_points
[
name
]
=
net
...
...
This diff is collapsed.
Click to expand it.
bob/learn/tensorflow/network/InceptionResnetV2.py
+
0
−
1
View file @
6809b360
...
@@ -259,7 +259,6 @@ def inception_resnet_v2_batch_norm(inputs,
...
@@ -259,7 +259,6 @@ def inception_resnet_v2_batch_norm(inputs,
'
updates_collections
'
:
None
,
'
updates_collections
'
:
None
,
}
}
weight_decay
=
5e-5
with
slim
.
arg_scope
(
with
slim
.
arg_scope
(
[
slim
.
conv2d
,
slim
.
fully_connected
],
[
slim
.
conv2d
,
slim
.
fully_connected
],
weights_initializer
=
tf
.
truncated_normal_initializer
(
stddev
=
0.1
),
weights_initializer
=
tf
.
truncated_normal_initializer
(
stddev
=
0.1
),
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment