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
6539ea67
Commit
6539ea67
authored
Nov 07, 2015
by
Davis King
Browse files
Added prototypes for batch normalization's gradients.
parent
51ebcfc7
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
46 additions
and
1 deletion
+46
-1
dlib/dnn/cuda_dlib.h
dlib/dnn/cuda_dlib.h
+46
-1
No files found.
dlib/dnn/cuda_dlib.h
View file @
6539ea67
...
@@ -52,7 +52,6 @@ namespace dlib
...
@@ -52,7 +52,6 @@ namespace dlib
// -----------------------------------------------------------------------------------
// -----------------------------------------------------------------------------------
// TODO, add versions of batch_normalize() that output the gradients.
void
batch_normalize
(
void
batch_normalize
(
resizable_tensor
&
dest
,
resizable_tensor
&
dest
,
resizable_tensor
&
means
,
resizable_tensor
&
means
,
...
@@ -63,6 +62,7 @@ namespace dlib
...
@@ -63,6 +62,7 @@ namespace dlib
);
);
/*!
/*!
requires
requires
- src.num_samples() > 1
- gamma.num_samples() == 1
- gamma.num_samples() == 1
- beta.num_samples() == 1
- beta.num_samples() == 1
- gamma.nr() == beta.nr() == src.nr()
- gamma.nr() == beta.nr() == src.nr()
...
@@ -80,6 +80,39 @@ namespace dlib
...
@@ -80,6 +80,39 @@ namespace dlib
- #vars == the variance values of the contents of src.
- #vars == the variance values of the contents of src.
!*/
!*/
void
batch_normalize_gradient
(
const
tensor
&
gradient_input
,
const
tensor
&
means
,
const
tensor
&
vars
,
const
tensor
&
src
,
const
tensor
&
gamma
,
tensor
&
src_grad
,
tensor
&
gamma_grad
,
tensor
&
beta_grad
);
/*!
requires
- vars and means should be the output of a call to
batch_normalize(dest,means,vars,src,gamma,beta)
- have_same_dimensions(gradient_input, src) == true
- have_same_dimensions(src, src_grad) == true
- src.num_samples() > 1
- gamma.num_samples() == 1
- have_same_dimensions(gamma, gamma_grad) == true
- have_same_dimensions(gamma, beta_grad) == true
- gamma.nr() == src.nr()
- gamma.nc() == src.nc()
- gamma.k() == src.k()
- have_same_dimensions(means, gamma) == true
- have_same_dimensions(vars, gamma) == true
ensures
- Let f(src,gamma,beta) == dot(gradient_input, dest output of
batch_normalize(dest,means,vars,src,gamma,beta))
- Adds the gradient of f() with respect to src to #src
- Adds the gradient of f() with respect to gamma to #gamma
- Adds the gradient of f() with respect to beta to #beta
!*/
void
batch_normalize_conv
(
void
batch_normalize_conv
(
resizable_tensor
&
dest
,
resizable_tensor
&
dest
,
resizable_tensor
&
means
,
resizable_tensor
&
means
,
...
@@ -90,6 +123,7 @@ namespace dlib
...
@@ -90,6 +123,7 @@ namespace dlib
);
);
/*!
/*!
requires
requires
- src.num_samples() > 1
- gamma.num_samples()==gamma.nr()==gamma.nc() == 1
- gamma.num_samples()==gamma.nr()==gamma.nc() == 1
- beta.num_samples() ==beta.nr() ==gamma.nc() == 1
- beta.num_samples() ==beta.nr() ==gamma.nc() == 1
- gamma.k() == beta.k() == src.k()
- gamma.k() == beta.k() == src.k()
...
@@ -103,6 +137,17 @@ namespace dlib
...
@@ -103,6 +137,17 @@ namespace dlib
- #vars == the variance values of the contents of src.
- #vars == the variance values of the contents of src.
!*/
!*/
void
batch_normalize_conv_gradient
(
const
tensor
&
gradient_input
,
const
tensor
&
means
,
const
tensor
&
vars
,
const
tensor
&
src
,
const
tensor
&
gamma
,
tensor
&
src_grad
,
tensor
&
gamma_grad
,
tensor
&
beta_grad
);
// -----------------------------------------------------------------------------------
// -----------------------------------------------------------------------------------
class
dropout
class
dropout
...
...
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