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
ca4f95ed
Commit
ca4f95ed
authored
Oct 08, 2015
by
Davis King
Browse files
Made the fc layer output 1x1 images with many feature maps.
parent
50143615
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
2 additions
and
8 deletions
+2
-8
dlib/dnn/layers.h
dlib/dnn/layers.h
+1
-7
dlib/dnn/layers_abstract.h
dlib/dnn/layers_abstract.h
+1
-1
No files found.
dlib/dnn/layers.h
View file @
ca4f95ed
...
@@ -77,15 +77,13 @@ namespace dlib
...
@@ -77,15 +77,13 @@ namespace dlib
num_inputs
=
sub
.
get_output
().
nr
()
*
sub
.
get_output
().
nc
()
*
sub
.
get_output
().
k
();
num_inputs
=
sub
.
get_output
().
nr
()
*
sub
.
get_output
().
nc
()
*
sub
.
get_output
().
k
();
params
.
set_size
(
num_inputs
,
num_outputs
);
params
.
set_size
(
num_inputs
,
num_outputs
);
std
::
cout
<<
"fc_::setup() "
<<
params
.
size
()
<<
std
::
endl
;
randomize_parameters
(
params
,
num_inputs
+
num_outputs
,
rnd
);
randomize_parameters
(
params
,
num_inputs
+
num_outputs
,
rnd
);
}
}
template
<
typename
SUBNET
>
template
<
typename
SUBNET
>
void
forward
(
const
SUBNET
&
sub
,
resizable_tensor
&
output
)
void
forward
(
const
SUBNET
&
sub
,
resizable_tensor
&
output
)
{
{
output
.
set_size
(
sub
.
get_output
().
num_samples
(),
num_outputs
);
output
.
set_size
(
sub
.
get_output
().
num_samples
(),
1
,
1
,
num_outputs
);
output
=
mat
(
sub
.
get_output
())
*
mat
(
params
);
output
=
mat
(
sub
.
get_output
())
*
mat
(
params
);
}
}
...
@@ -93,10 +91,6 @@ namespace dlib
...
@@ -93,10 +91,6 @@ namespace dlib
template
<
typename
SUBNET
>
template
<
typename
SUBNET
>
void
backward
(
const
tensor
&
gradient_input
,
SUBNET
&
sub
,
tensor
&
params_grad
)
void
backward
(
const
tensor
&
gradient_input
,
SUBNET
&
sub
,
tensor
&
params_grad
)
{
{
// d1*W*p1 + d2*W*p2
// total gradient = [d1*W; d2*W; d3*W; ...] == D*W
// compute the gradient of the parameters.
// compute the gradient of the parameters.
params_grad
+=
trans
(
mat
(
sub
.
get_output
()))
*
mat
(
gradient_input
);
params_grad
+=
trans
(
mat
(
sub
.
get_output
()))
*
mat
(
gradient_input
);
...
...
dlib/dnn/layers_abstract.h
View file @
ca4f95ed
...
@@ -252,7 +252,7 @@ namespace dlib
...
@@ -252,7 +252,7 @@ namespace dlib
- This layer outputs column vectors that contain get_num_outputs()
- This layer outputs column vectors that contain get_num_outputs()
elements. That is, the output tensor T from forward() will be such that:
elements. That is, the output tensor T from forward() will be such that:
- T.num_samples() == however many samples were given to forward().
- T.num_samples() == however many samples were given to forward().
- T.
nr
() == get_num_outputs()
- T.
k
() == get_num_outputs()
- The rest of the dimensions of T will be 1.
- The rest of the dimensions of T will be 1.
!*/
!*/
...
...
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