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
3a91295e
Commit
3a91295e
authored
Jun 13, 2017
by
Joachim
Browse files
Merge branch 'master' of
https://github.com/davisking/dlib
parents
22164e5d
75f66582
Changes
122
Hide whitespace changes
Inline
Side-by-side
Showing
20 changed files
with
105 additions
and
57 deletions
+105
-57
dlib/sockstreambuf/sockstreambuf_unbuffered.h
dlib/sockstreambuf/sockstreambuf_unbuffered.h
+1
-1
dlib/sqlite/sqlite.h
dlib/sqlite/sqlite.h
+6
-4
dlib/svm/kkmeans.h
dlib/svm/kkmeans.h
+4
-4
dlib/svm/pegasos.h
dlib/svm/pegasos.h
+2
-2
dlib/svm/structural_svm_distributed.h
dlib/svm/structural_svm_distributed.h
+7
-8
dlib/svm/svm_threaded.h
dlib/svm/svm_threaded.h
+5
-5
dlib/test/CMakeLists.txt
dlib/test/CMakeLists.txt
+0
-1
dlib/test/dnn.cpp
dlib/test/dnn.cpp
+30
-0
dlib/test/elastic_net.cpp
dlib/test/elastic_net.cpp
+1
-1
dlib/test/gui/main.cpp
dlib/test/gui/main.cpp
+8
-5
dlib/test/makefile
dlib/test/makefile
+0
-1
dlib/test/opt_qp_solver.cpp
dlib/test/opt_qp_solver.cpp
+10
-2
dlib/test/optimization_test_functions.cpp
dlib/test/optimization_test_functions.cpp
+1
-1
dlib/test/smart_pointers.cpp
dlib/test/smart_pointers.cpp
+3
-0
dlib/test/sockets.cpp
dlib/test/sockets.cpp
+5
-3
dlib/test/sockets2.cpp
dlib/test/sockets2.cpp
+9
-7
dlib/test/sockstreambuf.cpp
dlib/test/sockstreambuf.cpp
+4
-4
dlib/test/tester.h
dlib/test/tester.h
+1
-1
dlib/test/tuple.cpp
dlib/test/tuple.cpp
+4
-4
dlib/threads/thread_function_extension.h
dlib/threads/thread_function_extension.h
+4
-3
No files found.
dlib/sockstreambuf/sockstreambuf_unbuffered.h
View file @
3a91295e
...
...
@@ -57,7 +57,7 @@ namespace dlib
{}
sockstreambuf_unbuffered
(
const
s
coped
_ptr
<
connection
>&
con_
const
s
td
::
unique
_ptr
<
connection
>&
con_
)
:
con
(
*
con_
),
peek
(
EOF
),
...
...
dlib/sqlite/sqlite.h
View file @
3a91295e
...
...
@@ -6,12 +6,14 @@
#include "sqlite_abstract.h"
#include <iostream>
#include <limits>
#include <memory>
#include <vector>
#include "../algs.h"
#include <sqlite3.h>
#include "../smart_pointers.h"
#include "../serialize.h"
#include <limits>
// --------------------------------------------------------------------------------------------
...
...
@@ -105,7 +107,7 @@ namespace dlib
friend
class
statement
;
std
::
string
filename
;
shared_ptr
<
sqlite3
>
db
;
std
::
shared_ptr
<
sqlite3
>
db
;
};
// --------------------------------------------------------------------------------------------
...
...
@@ -593,7 +595,7 @@ namespace dlib
int
step_status
;
bool
at_first_step
;
shared_ptr
<
sqlite3
>
db
;
std
::
shared_ptr
<
sqlite3
>
db
;
sqlite3_stmt
*
stmt
;
std
::
string
sql_string
;
};
...
...
dlib/svm/kkmeans.h
View file @
3a91295e
...
...
@@ -4,6 +4,8 @@
#define DLIB_KKMEANs_
#include <cmath>
#include <vector>
#include "../matrix/matrix_abstract.h"
#include "../algs.h"
#include "../serialize.h"
...
...
@@ -12,8 +14,6 @@
#include "kcentroid.h"
#include "kkmeans_abstract.h"
#include "../noncopyable.h"
#include "../smart_pointers.h"
#include <vector>
namespace
dlib
{
...
...
@@ -176,7 +176,7 @@ namespace dlib
item
.
centers
.
resize
(
num
);
for
(
unsigned
long
i
=
0
;
i
<
item
.
centers
.
size
();
++
i
)
{
s
coped
_ptr
<
kcentroid
<
kernel_type
>
>
temp
(
new
kcentroid
<
kernel_type
>
(
kernel_type
()));
s
td
::
unique
_ptr
<
kcentroid
<
kernel_type
>
>
temp
(
new
kcentroid
<
kernel_type
>
(
kernel_type
()));
deserialize
(
*
temp
,
in
);
item
.
centers
[
i
].
swap
(
temp
);
}
...
...
@@ -270,7 +270,7 @@ namespace dlib
}
array
<
s
coped
_ptr
<
kcentroid
<
kernel_type
>
>
>
centers
;
array
<
s
td
::
unique
_ptr
<
kcentroid
<
kernel_type
>
>
>
centers
;
kcentroid
<
kernel_type
>
kc
;
scalar_type
min_change
;
...
...
dlib/svm/pegasos.h
View file @
3a91295e
...
...
@@ -10,7 +10,7 @@
#include "kernel.h"
#include "kcentroid.h"
#include <iostream>
#include
"../smart_pointers.h"
#include
<memory>
namespace
dlib
{
...
...
@@ -460,7 +460,7 @@ namespace dlib
const
sample_vector_type
*
samples
;
shared_ptr
<
cache_type
>
cache
;
std
::
shared_ptr
<
cache_type
>
cache
;
mutable
unsigned
long
counter
;
unsigned
long
counter_threshold
;
long
cache_size
;
...
...
dlib/svm/structural_svm_distributed.h
View file @
3a91295e
...
...
@@ -3,20 +3,19 @@
#ifndef DLIB_STRUCTURAL_SVM_DISTRIBUTeD_Hh_
#define DLIB_STRUCTURAL_SVM_DISTRIBUTeD_Hh_
#include <memory>
#include <iostream>
#include <vector>
#include "structural_svm_distributed_abstract.h"
#include "structural_svm_problem.h"
#include "../bridge.h"
#include "../smart_pointers.h"
#include "../misc_api.h"
#include "../statistics.h"
#include "../threads.h"
#include "../pipe.h"
#include "../type_safe_union.h"
#include <iostream>
#include <vector>
namespace
dlib
{
...
...
@@ -333,7 +332,7 @@ namespace dlib
};
s
coped
_ptr
<
base
>
the_problem
;
s
td
::
unique
_ptr
<
base
>
the_problem
;
};
// ----------------------------------------------------------------------------------------
...
...
@@ -678,9 +677,9 @@ namespace dlib
typedef
type_safe_union
<
impl
::
oracle_request
<
matrix_type
>
>
tsu_out
;
typedef
type_safe_union
<
impl
::
oracle_response
<
matrix_type
>
,
long
>
tsu_in
;
std
::
vector
<
shared_ptr
<
pipe
<
tsu_out
>
>
>
out_pipes
;
std
::
vector
<
std
::
shared_ptr
<
pipe
<
tsu_out
>
>
>
out_pipes
;
mutable
pipe
<
tsu_in
>
in
;
std
::
vector
<
shared_ptr
<
bridge
>
>
bridges
;
std
::
vector
<
std
::
shared_ptr
<
bridge
>
>
bridges
;
long
num_dims
;
};
...
...
dlib/svm/svm_threaded.h
View file @
3a91295e
...
...
@@ -3,21 +3,21 @@
#ifndef DLIB_SVm_THREADED_
#define DLIB_SVm_THREADED_
#include "svm_threaded_abstract.h"
#include "svm.h"
#include <cmath>
#include <iostream>
#include <limits>
#include <sstream>
#include <vector>
#include "svm_threaded_abstract.h"
#include "svm.h"
#include "../matrix.h"
#include "../algs.h"
#include "../serialize.h"
#include "function.h"
#include "kernel.h"
#include "../threads.h"
#include <vector>
#include "../smart_pointers.h"
#include "../pipe.h"
#include <iostream>
namespace
dlib
{
...
...
dlib/test/CMakeLists.txt
View file @
3a91295e
...
...
@@ -125,7 +125,6 @@ set (tests
set.cpp
sldf.cpp
sliding_buffer.cpp
smart_pointers.cpp
sockets2.cpp
sockets.cpp
sockstreambuf.cpp
...
...
dlib/test/dnn.cpp
View file @
3a91295e
...
...
@@ -692,6 +692,36 @@ namespace
cpu
::
add
(
2
,
AA
,
3
,
BB
);
DLIB_TEST_MSG
(
max
(
abs
(
mat
(
A
)
-
mat
(
AA
)
))
<
1e-6
,
max
(
abs
(
mat
(
A
)
-
mat
(
AA
)
)));
}
{
print_spinner
();
resizable_tensor
dest1
(
123
,
456
),
dest2
(
123
,
456
);
resizable_tensor
src1
(
123
,
456
),
src2
(
123
,
456
);
tt
::
tensor_rand
rnd
;
rnd
.
fill_uniform
(
src1
);
tt
::
affine_transform
(
src1
,
src1
,
1
,
2
);
src2
=
src1
;
// random in range [2, 3]
dest1
=
exp
(
mat
(
src1
));
tt
::
exp
(
dest2
,
src2
);
tt
::
exp
(
src2
,
src2
);
// should work in place
DLIB_TEST_MSG
(
max
(
abs
(
mat
(
dest1
)
-
mat
(
dest2
)))
<
1e-5
,
max
(
abs
(
mat
(
dest1
)
-
mat
(
dest2
))));
DLIB_TEST
(
max
(
abs
(
mat
(
dest1
)
-
mat
(
src2
)))
<
1e-5
);
rnd
.
fill_uniform
(
src1
);
tt
::
affine_transform
(
src1
,
src1
,
1
,
2
);
src2
=
src1
;
// random in range [2, 3]
dest1
=
log
(
mat
(
src1
));
tt
::
log
(
dest2
,
src2
);
tt
::
log
(
src2
,
src2
);
// should work in place
DLIB_TEST
(
max
(
abs
(
mat
(
dest1
)
-
mat
(
dest2
)))
<
1e-5
);
DLIB_TEST
(
max
(
abs
(
mat
(
dest1
)
-
mat
(
src2
)))
<
1e-5
);
rnd
.
fill_uniform
(
src1
);
tt
::
affine_transform
(
src1
,
src1
,
1
,
2
);
src2
=
src1
;
// random in range [2, 3]
dest1
=
log10
(
mat
(
src1
));
tt
::
log10
(
dest2
,
src2
);
tt
::
log10
(
src2
,
src2
);
// should work in place
DLIB_TEST
(
max
(
abs
(
mat
(
dest1
)
-
mat
(
dest2
)))
<
1e-5
);
DLIB_TEST
(
max
(
abs
(
mat
(
dest1
)
-
mat
(
src2
)))
<
1e-5
);
}
}
// ----------------------------------------------------------------------------------------
...
...
dlib/test/elastic_net.cpp
View file @
3a91295e
...
...
@@ -109,7 +109,7 @@ namespace
results
=
basic_elastic_net
(
X
,
Y
,
ridge_lambda
,
lasso_budget
*
s
,
eps
);
results2
=
solver
(
ridge_lambda
,
lasso_budget
*
s
);
dlog
<<
LINFO
<<
"error: "
<<
max
(
abs
(
results
-
results2
));
DLIB_TEST
(
max
(
abs
(
results
-
results2
)
<
1e-3
)
)
;
DLIB_TEST
(
max
(
abs
(
results
-
results2
)
)
<
1e-3
);
}
}
}
a
;
...
...
dlib/test/gui/main.cpp
View file @
3a91295e
#include <fstream>
#include <iostream>
#include <memory>
#include <sstream>
#include <string>
#include "dlib/image_io.h"
#include "dlib/array2d.h"
#include "dlib/gui_core.h"
#include "dlib/assert.h"
#include "dlib/misc_api.h"
#include <string>
#include "dlib/image_transforms.h"
#include "dlib/timer.h"
#include "dlib/gui_widgets.h"
#include "dlib/queue.h"
#include <sstream>
#include <iostream>
#include <fstream>
using
namespace
dlib
;
using
namespace
std
;
...
...
@@ -444,7 +447,7 @@ public:
{
bool
use_bdf_fonts
=
false
;
shared_ptr
_thread_safe
<
bdf_font
>
f
(
new
bdf_font
);
std
::
shared_ptr
<
bdf_font
>
f
(
new
bdf_font
);
if
(
use_bdf_fonts
)
{
...
...
dlib/test/makefile
View file @
3a91295e
...
...
@@ -131,7 +131,6 @@ SRC += serialize.cpp
SRC
+=
set.cpp
SRC
+=
sldf.cpp
SRC
+=
sliding_buffer.cpp
SRC
+=
smart_pointers.cpp
SRC
+=
sockets2.cpp
SRC
+=
sockets.cpp
SRC
+=
sockstreambuf.cpp
...
...
dlib/test/opt_qp_solver.cpp
View file @
3a91295e
...
...
@@ -287,13 +287,16 @@ namespace
const
double
C
=
2
;
matrix
<
double
,
0
,
1
>
alpha
(
3
),
d
(
3
),
lambda
;
d
=
0
;
alpha
=
C
/
2
,
C
/
2
,
0
;
solve_qp4_using_smo
(
A
,
tmp
(
trans
(
A
)
*
A
),
b
,
d
,
alpha
,
lambda
,
1e-9
,
3000
);
unsigned
long
iters
=
solve_qp4_using_smo
(
A
,
tmp
(
trans
(
A
)
*
A
),
b
,
d
,
alpha
,
lambda
,
1e-9
,
3000
);
matrix
<
double
,
0
,
1
>
w
=
lowerbound
(
-
A
*
alpha
,
0
);
dlog
<<
LINFO
<<
"*******************************************************"
;
dlog
<<
LINFO
<<
"alpha: "
<<
trans
(
alpha
);
dlog
<<
LINFO
<<
"lambda: "
<<
trans
(
lambda
);
dlog
<<
LINFO
<<
"w: "
<<
trans
(
w
);
...
...
@@ -303,7 +306,12 @@ namespace
dlog
<<
LINFO
<<
"computed obj: "
<<
computed_obj
;
dlog
<<
LINFO
<<
"with true w obj: "
<<
true_obj
;
DLIB_TEST_MSG
(
abs
(
computed_obj
-
true_obj
)
<
1e-8
,
abs
(
computed_obj
-
true_obj
));
DLIB_TEST_MSG
(
abs
(
computed_obj
-
true_obj
)
<
1e-8
,
"computed_obj: "
<<
computed_obj
<<
" true_obj: "
<<
true_obj
<<
" delta: "
<<
abs
(
computed_obj
-
true_obj
)
<<
" iters: "
<<
iters
<<
"
\n
alpha: "
<<
trans
(
alpha
)
<<
" lambda: "
<<
trans
(
lambda
)
);
}
void
test_qp4_test7
()
...
...
dlib/test/optimization_test_functions.cpp
View file @
3a91295e
...
...
@@ -378,7 +378,7 @@ namespace dlib
h
(
0
,
3
)
=
h
(
0
,
3
)
+
8.0E+00
*
f1
*
f2
*
df1dx1
*
df2dx4
;
h
(
1
,
0
)
=
h
(
1
,
0
)
+
12.0E+00
*
pow
(
f1
,
2
)
*
df1dx2
*
df1dx1
+
4.0E+00
*
pow
(
f2
,
2
)
*
df1dx2
*
df1dx1
;
h
(
1
,
1
)
=
h
(
1
,
1
)
+
12.0E+00
*
pow
(
f1
,
2
)
*
df1dx2
*
df1dx2
+
4.0E+00
*
pow
(
f2
,
2
)
*
df1dx2
*
df1dx
1
;
h
(
1
,
1
)
=
h
(
1
,
1
)
+
12.0E+00
*
pow
(
f1
,
2
)
*
df1dx2
*
df1dx2
+
4.0E+00
*
pow
(
f2
,
2
)
*
df1dx2
*
df1dx
2
;
h
(
1
,
2
)
=
h
(
1
,
2
)
+
8.0E+00
*
f1
*
f2
*
df1dx2
*
df2dx3
;
h
(
1
,
3
)
=
h
(
1
,
3
)
+
8.0E+00
*
f1
*
f2
*
df1dx2
*
df2dx4
;
...
...
dlib/test/smart_pointers.cpp
View file @
3a91295e
// Copyright (C) 2007 Davis E. King (davis@dlib.net)
// License: Boost Software License See LICENSE.txt for the full license.
// This is a legacy test for old dlib smart pointers which is excluded
// from CMakeLists.txt. Including this test will pull legacy smart_pointers.h
// code which is uncompilable on C++17 compilers
#include <dlib/smart_pointers.h>
#include <sstream>
...
...
dlib/test/sockets.cpp
View file @
3a91295e
...
...
@@ -2,10 +2,12 @@
// License: Boost Software License See LICENSE.txt for the full license.
#include <sstream>
#include <string>
#include <cstdlib>
#include <ctime>
#include <memory>
#include <sstream>
#include <string>
#include <dlib/sockets.h>
#include <dlib/server.h>
#include <dlib/misc_api.h>
...
...
@@ -118,7 +120,7 @@ namespace {
}
int
status
;
s
coped
_ptr
<
connection
>
con
;
s
td
::
unique
_ptr
<
connection
>
con
;
string
hostname
;
string
ip
;
status
=
get_local_hostname
(
hostname
);
...
...
dlib/test/sockets2.cpp
View file @
3a91295e
// Copyright (C) 2008 Davis E. King (davis@dlib.net)
// License: Boost Software License See LICENSE.txt for the full license.
#include <algorithm>
#include <memory>
#include "tester.h"
#include <dlib/sockets.h>
#include <dlib/threads.h>
#include <dlib/array.h>
#include <algorithm>
// This is called an unnamed-namespace and it has the effect of making everything
// inside this file "private" so that everything you declare will have static linkage.
...
...
@@ -39,7 +41,7 @@ namespace
{
try
{
s
coped
_ptr
<
connection
>
con
(
connect
(
"127.0.0.1"
,
port_num
));
s
td
::
unique
_ptr
<
connection
>
con
(
connect
(
"127.0.0.1"
,
port_num
));
// Send a copy of the data down the connection so we can test our the read() function
// that uses timeouts in the main thread.
...
...
@@ -63,7 +65,7 @@ namespace
{
try
{
s
coped
_ptr
<
connection
>
con
(
connect
(
"127.0.0.1"
,
port_num
));
s
td
::
unique
_ptr
<
connection
>
con
(
connect
(
"127.0.0.1"
,
port_num
));
// just do nothing until the connection closes
char
ch
;
...
...
@@ -120,17 +122,17 @@ namespace
dlog
<<
LINFO
<<
"data block size: "
<<
data_to_send
.
size
();
s
coped
_ptr
<
listener
>
list
;
s
td
::
unique
_ptr
<
listener
>
list
;
DLIB_TEST
(
create_listener
(
list
,
port_num
,
"127.0.0.1"
)
==
0
);
DLIB_TEST
(
list
);
DLIB_TEST
(
bool
(
list
)
)
;
// kick off the sending threads
start
();
dlib
::
array
<
s
coped
_ptr
<
connection
>
>
cons
;
dlib
::
array
<
s
td
::
unique
_ptr
<
connection
>
>
cons
;
std
::
vector
<
long
>
bytes_received
(
6
,
0
);
s
coped
_ptr
<
connection
>
con_temp
;
s
td
::
unique
_ptr
<
connection
>
con_temp
;
// accept the 6 connections we should get
for
(
int
i
=
0
;
i
<
6
;
++
i
)
...
...
dlib/test/sockstreambuf.cpp
View file @
3a91295e
...
...
@@ -2,15 +2,15 @@
// License: Boost Software License See LICENSE.txt for the full license.
#include <cstdlib>
#include <sstream>
#include <string>
#include <cstdlib>
#include <vector>
#include <ctime>
#include <dlib/sockets.h>
#include <dlib/misc_api.h>
#include <dlib/sockstreambuf.h>
#include <vector>
#include <dlib/smart_pointers.h>
#include "tester.h"
...
...
@@ -143,7 +143,7 @@ namespace
}
// make sure con gets deleted
s
coped
_ptr
<
connection
>
del_con
(
con
);
s
td
::
unique
_ptr
<
connection
>
del_con
(
con
);
ssb
buf
(
con
);
istream
in
(
&
buf
);
...
...
dlib/test/tester.h
View file @
3a91295e
...
...
@@ -17,7 +17,7 @@
#endif
#define DLIB_TEST(_exp) check_test(_exp, __LINE__, __FILE__, #_exp)
#define DLIB_TEST(_exp) check_test(
bool(
_exp
)
, __LINE__, __FILE__, #_exp)
#define DLIB_TEST_MSG(_exp,_message) \
do{increment_test_count(); if ( !(_exp) ) \
...
...
dlib/test/tuple.cpp
View file @
3a91295e
...
...
@@ -18,7 +18,7 @@ namespace
logger
dlog
(
"test.tuple"
);
struct
nil
struct
s_
nil
{
template
<
typename
T
>
void
operator
()
(
...
...
@@ -122,10 +122,10 @@ namespace
b
=
a
;
inc
i
;
nil
n
;
s_
nil
n
;
a
.
for_each
(
inc
());
a
.
for_each
(
i
);
const_cast
<
const
T
&>
(
a
).
for_each
(
nil
());
const_cast
<
const
T
&>
(
a
).
for_each
(
s_
nil
());
const_cast
<
const
T
&>
(
a
).
for_each
(
n
);
DLIB_TEST
(
a
.
get
<
0
>
()
==
b
.
get
<
0
>
()
+
2
);
...
...
@@ -145,7 +145,7 @@ namespace
a
.
for_index
(
i
,
0
);
a
.
for_index
(
inc
(),
1
);
const_cast
<
const
T
&>
(
a
).
for_index
(
n
,
2
);
const_cast
<
const
T
&>
(
a
).
for_index
(
nil
(),
0
);
const_cast
<
const
T
&>
(
a
).
for_index
(
s_
nil
(),
0
);
DLIB_TEST
(
a
.
get
<
0
>
()
==
b
.
get
<
0
>
()
+
1
);
DLIB_TEST
(
a
.
get
<
1
>
()
==
b
.
get
<
1
>
()
+
1
);
...
...
dlib/threads/thread_function_extension.h
View file @
3a91295e
// Copyright (C) 2007 Davis E. King (davis@dlib.net)
// License: Boost Software License See LICENSE.txt for the full license.
#ifndef DLIB_THREAD_FUNCTIOn_
#define DLIB_THREAD_FUNCTIOn_
#define DLIB_THREAD_FUNCTIOn_
#include <memory>
#include "thread_function_extension_abstract.h"
#include "threads_kernel.h"
#include "auto_mutex_extension.h"
#include "threaded_object_extension.h"
#include "../smart_pointers.h"
namespace
dlib
{
...
...
@@ -197,7 +198,7 @@ namespace dlib
f
->
go
();
}
s
coped
_ptr
<
base_funct
>
f
;
s
td
::
unique
_ptr
<
base_funct
>
f
;
// restricted functions
thread_function
(
thread_function
&
);
// copy constructor
...
...
Prev
1
2
3
4
5
6
7
Next
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