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
OpenDAS
dlib
Commits
57ca3e54
Commit
57ca3e54
authored
Feb 08, 2017
by
Davis King
Browse files
Made network smaller.
parent
4dbe3337
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
20 additions
and
16 deletions
+20
-16
examples/dnn_metric_learning_on_images_ex.cpp
examples/dnn_metric_learning_on_images_ex.cpp
+20
-16
No files found.
examples/dnn_metric_learning_on_images_ex.cpp
View file @
57ca3e54
...
@@ -131,9 +131,9 @@ void load_mini_batch (
...
@@ -131,9 +131,9 @@ void load_mini_batch (
// ----------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------
// The next page of code defines
the
ResNet
-34
network. It's basically copied
// The next page of code defines
a
ResNet network. It's basically copied
// and pasted from the dnn_imagenet_ex.cpp example, except we replaced the loss
// and pasted from the dnn_imagenet_ex.cpp example, except we replaced the loss
// layer with loss_metric.
// layer with loss_metric
and make the network somewhat smaller
.
template
<
template
<
int
,
template
<
typename
>
class
,
int
,
typename
>
class
block
,
int
N
,
template
<
typename
>
class
BN
,
typename
SUBNET
>
template
<
template
<
int
,
template
<
typename
>
class
,
int
,
typename
>
class
block
,
int
N
,
template
<
typename
>
class
BN
,
typename
SUBNET
>
using
residual
=
add_prev1
<
block
<
N
,
BN
,
1
,
tag1
<
SUBNET
>>>
;
using
residual
=
add_prev1
<
block
<
N
,
BN
,
1
,
tag1
<
SUBNET
>>>
;
...
@@ -152,36 +152,40 @@ template <int N, typename SUBNET> using ares_down = relu<residual_down<block,N,a
...
@@ -152,36 +152,40 @@ template <int N, typename SUBNET> using ares_down = relu<residual_down<block,N,a
// ----------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------
template
<
typename
SUBNET
>
using
level1
=
res
<
512
,
res
<
512
,
res_down
<
512
,
SUBNET
>>>
;
template
<
typename
SUBNET
>
using
level0
=
res_down
<
256
,
SUBNET
>
;
template
<
typename
SUBNET
>
using
level2
=
res
<
256
,
res
<
256
,
res
<
256
,
res
<
256
,
res
<
256
,
res_down
<
256
,
SUBNET
>>>>>>
;
template
<
typename
SUBNET
>
using
level1
=
res
<
256
,
res
<
256
,
res_down
<
256
,
SUBNET
>>>
;
template
<
typename
SUBNET
>
using
level3
=
res
<
128
,
res
<
128
,
res
<
128
,
res_down
<
128
,
SUBNET
>>>>
;
template
<
typename
SUBNET
>
using
level2
=
res
<
128
,
res
<
128
,
res_down
<
128
,
SUBNET
>>>
;
template
<
typename
SUBNET
>
using
level4
=
res
<
64
,
res
<
64
,
res
<
64
,
SUBNET
>>>
;
template
<
typename
SUBNET
>
using
level3
=
res
<
64
,
res
<
64
,
res
<
64
,
res_down
<
64
,
SUBNET
>>>>
;
template
<
typename
SUBNET
>
using
level4
=
res
<
32
,
res
<
32
,
res
<
32
,
SUBNET
>>>
;
template
<
typename
SUBNET
>
using
alevel1
=
ares
<
512
,
ares
<
512
,
ares_down
<
512
,
SUBNET
>>>
;
template
<
typename
SUBNET
>
using
alevel0
=
ares_down
<
256
,
SUBNET
>
;
template
<
typename
SUBNET
>
using
alevel2
=
ares
<
256
,
ares
<
256
,
ares
<
256
,
ares
<
256
,
ares
<
256
,
ares_down
<
256
,
SUBNET
>>>>>>
;
template
<
typename
SUBNET
>
using
alevel1
=
ares
<
256
,
ares
<
256
,
ares_down
<
256
,
SUBNET
>>>
;
template
<
typename
SUBNET
>
using
alevel3
=
ares
<
128
,
ares
<
128
,
ares
<
128
,
ares_down
<
128
,
SUBNET
>>>>
;
template
<
typename
SUBNET
>
using
alevel2
=
ares
<
128
,
ares
<
128
,
ares_down
<
128
,
SUBNET
>>>
;
template
<
typename
SUBNET
>
using
alevel4
=
ares
<
64
,
ares
<
64
,
ares
<
64
,
SUBNET
>>>
;
template
<
typename
SUBNET
>
using
alevel3
=
ares
<
64
,
ares
<
64
,
ares
<
64
,
ares_down
<
64
,
SUBNET
>>>>
;
template
<
typename
SUBNET
>
using
alevel4
=
ares
<
32
,
ares
<
32
,
ares
<
32
,
SUBNET
>>>
;
// training network type
// training network type
using
net_type
=
loss_metric
<
fc_no_bias
<
128
,
avg_pool_everything
<
using
net_type
=
loss_metric
<
fc_no_bias
<
128
,
avg_pool_everything
<
level0
<
level1
<
level1
<
level2
<
level2
<
level3
<
level3
<
level4
<
level4
<
max_pool
<
3
,
3
,
2
,
2
,
relu
<
bn_con
<
con
<
64
,
7
,
7
,
2
,
2
,
max_pool
<
3
,
3
,
2
,
2
,
relu
<
bn_con
<
con
<
32
,
7
,
7
,
2
,
2
,
input_rgb_image
input_rgb_image
_sized
<
150
>
>>>>>>>>>>>
;
>>>>>>>>>>>
>
;
// testing network type (replaced batch normalization with fixed affine transforms)
// testing network type (replaced batch normalization with fixed affine transforms)
using
anet_type
=
loss_metric
<
fc_no_bias
<
128
,
avg_pool_everything
<
using
anet_type
=
loss_metric
<
fc_no_bias
<
128
,
avg_pool_everything
<
alevel0
<
alevel1
<
alevel1
<
alevel2
<
alevel2
<
alevel3
<
alevel3
<
alevel4
<
alevel4
<
max_pool
<
3
,
3
,
2
,
2
,
relu
<
affine
<
con
<
64
,
7
,
7
,
2
,
2
,
max_pool
<
3
,
3
,
2
,
2
,
relu
<
affine
<
con
<
32
,
7
,
7
,
2
,
2
,
input_rgb_image
input_rgb_image
_sized
<
150
>
>>>>>>>>>>>
;
>>>>>>>>>>>
>
;
// ----------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------
...
...
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