Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
D
dlib
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
钟尚武
dlib
Commits
fdf2a454
Commit
fdf2a454
authored
Feb 07, 2016
by
Davis King
Browse files
Options
Browse Files
Download
Plain Diff
merged
parents
5e4350ca
c9090bfd
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
139 additions
and
0 deletions
+139
-0
serialize.h
dlib/serialize.h
+53
-0
running_gradient.h
dlib/statistics/running_gradient.h
+45
-0
running_gradient_abstract.h
dlib/statistics/running_gradient_abstract.h
+39
-0
term_index.xml
docs/docs/term_index.xml
+2
-0
No files found.
dlib/serialize.h
View file @
fdf2a454
...
...
@@ -62,6 +62,7 @@
- std::string
- std::wstring
- std::vector
- std::deque
- std::map
- std::set
- std::pair
...
...
@@ -79,6 +80,7 @@
- std::string
- std::wstring
- std::vector
- std::deque
- std::map
- std::set
- std::pair
...
...
@@ -143,6 +145,7 @@
#include <fstream>
#include <string>
#include <vector>
#include <deque>
#include <complex>
#include <map>
#include <set>
...
...
@@ -652,6 +655,18 @@ namespace dlib
std
::
istream
&
in
);
template
<
typename
T
,
typename
alloc
>
void
serialize
(
const
std
::
deque
<
T
,
alloc
>&
item
,
std
::
ostream
&
out
);
template
<
typename
T
,
typename
alloc
>
void
deserialize
(
std
::
deque
<
T
,
alloc
>&
item
,
std
::
istream
&
in
);
inline
void
serialize
(
const
std
::
string
&
item
,
std
::
ostream
&
out
...
...
@@ -1035,6 +1050,44 @@ namespace dlib
{
throw
serialization_error
(
e
.
info
+
"
\n
while deserializing object of type std::vector"
);
}
}
// ----------------------------------------------------------------------------------------
template
<
typename
T
,
typename
alloc
>
void
serialize
(
const
std
::
deque
<
T
,
alloc
>&
item
,
std
::
ostream
&
out
)
{
try
{
const
unsigned
long
size
=
static_cast
<
unsigned
long
>
(
item
.
size
());
serialize
(
size
,
out
);
for
(
unsigned
long
i
=
0
;
i
<
item
.
size
();
++
i
)
serialize
(
item
[
i
],
out
);
}
catch
(
serialization_error
&
e
)
{
throw
serialization_error
(
e
.
info
+
"
\n
while serializing object of type std::deque"
);
}
}
template
<
typename
T
,
typename
alloc
>
void
deserialize
(
std
::
deque
<
T
,
alloc
>&
item
,
std
::
istream
&
in
)
{
try
{
unsigned
long
size
;
deserialize
(
size
,
in
);
item
.
resize
(
size
);
for
(
unsigned
long
i
=
0
;
i
<
size
;
++
i
)
deserialize
(
item
[
i
],
in
);
}
catch
(
serialization_error
&
e
)
{
throw
serialization_error
(
e
.
info
+
"
\n
while deserializing object of type std::deque"
);
}
}
// ----------------------------------------------------------------------------------------
inline
void
serialize
(
...
...
dlib/statistics/running_gradient.h
View file @
fdf2a454
...
...
@@ -151,6 +151,51 @@ namespace dlib
matrix
<
double
,
2
,
1
>
w
;
double
residual_squared
;
};
// ----------------------------------------------------------------------------------------
template
<
typename
T
>
double
probability_gradient_less_than
(
const
T
&
container
,
double
thresh
)
{
running_gradient
g
;
for
(
auto
&&
v
:
container
)
g
.
add
(
v
);
// make sure requires clause is not broken
DLIB_ASSERT
(
g
.
current_n
()
>
2
,
"
\t
double probability_gradient_less_than()"
<<
"
\n\t
You need more than 2 elements in the given container to call this function."
);
return
g
.
probability_gradient_less_than
(
thresh
);
}
template
<
typename
T
>
double
probability_gradient_greater_than
(
const
T
&
container
,
double
thresh
)
{
running_gradient
g
;
for
(
auto
&&
v
:
container
)
g
.
add
(
v
);
// make sure requires clause is not broken
DLIB_ASSERT
(
g
.
current_n
()
>
2
,
"
\t
double probability_gradient_greater_than()"
<<
"
\n\t
You need more than 2 elements in the given container to call this function."
);
return
g
.
probability_gradient_greater_than
(
thresh
);
}
// ----------------------------------------------------------------------------------------
}
#endif // DLIB_RuNNING_GRADIENT_Hh_
...
...
dlib/statistics/running_gradient_abstract.h
View file @
fdf2a454
...
...
@@ -116,6 +116,45 @@ namespace dlib
/*!
provides serialization support
!*/
// ----------------------------------------------------------------------------------------
template
<
typename
T
>
double
probability_gradient_less_than
(
const
T
&
container
,
double
thresh
);
/*!
requires
- container muse be a container of double values that can be enumerated with a
range based for loop.
- The container must contain more than 2 elements.
ensures
- Puts all the elements of container into a running_gradient object, R, and
then returns R.probability_gradient_less_than(thresh).
!*/
template
<
typename
T
>
double
probability_gradient_greater_than
(
const
T
&
container
,
double
thresh
);
/*!
requires
- container muse be a container of double values that can be enumerated with a
range based for loop.
- The container must contain more than 2 elements.
ensures
- Puts all the elements of container into a running_gradient object, R, and
then returns R.probability_gradient_greater_than(thresh).
!*/
// ----------------------------------------------------------------------------------------
}
#endif // DLIB_RuNNING_GRADIENT_ABSTRACT_Hh_
...
...
docs/docs/term_index.xml
View file @
fdf2a454
...
...
@@ -258,6 +258,8 @@
<term
file=
"linear_algebra.html"
name=
"rotation_matrix"
include=
"dlib/geometry.h"
/>
<term
file=
"algorithms.html"
name=
"running_stats"
include=
"dlib/statistics.h"
/>
<term
file=
"algorithms.html"
name=
"running_gradient"
include=
"dlib/statistics/running_gradient.h"
/>
<term
file=
"dlib/statistics/running_gradient_abstract.h.html"
name=
"probability_gradient_greater_than"
include=
"dlib/statistics/running_gradient.h"
/>
<term
file=
"dlib/statistics/running_gradient_abstract.h.html"
name=
"probability_gradient_less_than"
include=
"dlib/statistics/running_gradient.h"
/>
<term
file=
"algorithms.html"
name=
"running_scalar_covariance"
include=
"dlib/statistics.h"
/>
<term
file=
"algorithms.html"
name=
"mean_sign_agreement"
include=
"dlib/statistics.h"
/>
<term
file=
"algorithms.html"
name=
"correlation"
include=
"dlib/statistics.h"
/>
...
...
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