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
4f411d5a
Commit
4f411d5a
authored
Jan 26, 2013
by
Davis King
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Made svm_struct_controller_node support network_address objects.
parent
cbc469bf
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
42 additions
and
23 deletions
+42
-23
structural_svm_distributed.h
dlib/svm/structural_svm_distributed.h
+19
-12
structural_svm_distributed_abstract.h
dlib/svm/structural_svm_distributed_abstract.h
+22
-10
svm_struct.cpp
dlib/test/svm_struct.cpp
+1
-1
No files found.
dlib/svm/structural_svm_distributed.h
View file @
4f411d5a
...
@@ -365,29 +365,36 @@ namespace dlib
...
@@ -365,29 +365,36 @@ namespace dlib
}
}
void
add_processing_node
(
void
add_processing_node
(
const
std
::
string
&
ip
,
const
network_address
&
addr
unsigned
short
port
)
)
{
{
// make sure requires clause is not broken
// make sure requires clause is not broken
DLIB_ASSERT
(
is_ip_address
(
ip
)
&&
port
!=
0
,
DLIB_ASSERT
(
addr
.
port
!=
0
,
"
\t
void structural_svm_problem::add_processing_node()"
"
\t
void structural_svm_problem::add_processing_node()"
<<
"
\n\t
Invalid inputs were given to this function"
<<
"
\n\t
Invalid inputs were given to this function"
<<
"
\n\t
ip: "
<<
ip
<<
"
\n\t
addr.host_address: "
<<
addr
.
host_address
<<
"
\n\t
port: "
<<
port
<<
"
\n\t
addr.port: "
<<
addr
.
port
<<
"
\n\t
this: "
<<
this
<<
"
\n\t
this: "
<<
this
);
);
// check if this
pair
is already registered
// check if this
address
is already registered
for
(
unsigned
long
i
=
0
;
i
<
nodes
.
size
();
++
i
)
for
(
unsigned
long
i
=
0
;
i
<
nodes
.
size
();
++
i
)
{
{
if
(
nodes
[
i
]
==
make_pair
(
ip
,
port
)
)
if
(
nodes
[
i
]
==
addr
)
{
{
return
;
return
;
}
}
}
}
nodes
.
push_back
(
addr
);
}
nodes
.
push_back
(
make_pair
(
ip
,
port
));
void
add_processing_node
(
const
std
::
string
&
ip_or_hostname
,
unsigned
short
port
)
{
add_processing_node
(
network_address
(
ip_or_hostname
,
port
));
}
}
unsigned
long
get_num_processing_nodes
(
unsigned
long
get_num_processing_nodes
(
...
@@ -439,7 +446,7 @@ namespace dlib
...
@@ -439,7 +446,7 @@ namespace dlib
typedef
matrix_type_
matrix_type
;
typedef
matrix_type_
matrix_type
;
problem_type
(
problem_type
(
const
std
::
vector
<
std
::
pair
<
std
::
string
,
unsigned
short
>
>&
nodes_
,
const
std
::
vector
<
network_address
>&
nodes_
,
double
eps_
,
double
eps_
,
bool
verbose_
,
bool
verbose_
,
double
C_
double
C_
...
@@ -465,7 +472,7 @@ namespace dlib
...
@@ -465,7 +472,7 @@ namespace dlib
bridges
.
resize
(
nodes
.
size
());
bridges
.
resize
(
nodes
.
size
());
for
(
unsigned
long
i
=
0
;
i
<
bridges
.
size
();
++
i
)
for
(
unsigned
long
i
=
0
;
i
<
bridges
.
size
();
++
i
)
{
{
bridges
[
i
].
reset
(
new
bridge
(
connect_to
_ip_and_port
(
nodes
[
i
].
first
,
nodes
[
i
].
second
),
bridges
[
i
].
reset
(
new
bridge
(
connect_to
(
nodes
[
i
]
),
receive
(
in
),
transmit
(
*
out_pipes
[
i
])));
receive
(
in
),
transmit
(
*
out_pipes
[
i
])));
}
}
...
@@ -605,7 +612,7 @@ namespace dlib
...
@@ -605,7 +612,7 @@ namespace dlib
risk
=
total_loss
+
dot
(
subgradient
,
w
);
risk
=
total_loss
+
dot
(
subgradient
,
w
);
}
}
std
::
vector
<
std
::
pair
<
std
::
string
,
unsigned
short
>
>
nodes
;
std
::
vector
<
network_address
>
nodes
;
double
eps
;
double
eps
;
mutable
bool
verbose
;
mutable
bool
verbose
;
double
C
;
double
C
;
...
@@ -622,7 +629,7 @@ namespace dlib
...
@@ -622,7 +629,7 @@ namespace dlib
long
num_dims
;
long
num_dims
;
};
};
std
::
vector
<
std
::
pair
<
std
::
string
,
unsigned
short
>
>
nodes
;
std
::
vector
<
network_address
>
nodes
;
double
eps
;
double
eps
;
mutable
bool
verbose
;
mutable
bool
verbose
;
double
C
;
double
C
;
...
...
dlib/svm/structural_svm_distributed_abstract.h
View file @
4f411d5a
...
@@ -88,9 +88,9 @@ namespace dlib
...
@@ -88,9 +88,9 @@ namespace dlib
svm_struct_controller_node cont;
svm_struct_controller_node cont;
cont.set_c(100);
cont.set_c(100);
// Tell cont where the processing nodes are on your network.
// Tell cont where the processing nodes are on your network.
cont.add_processing_node("192.168.1.10
", 12345
);
cont.add_processing_node("192.168.1.10
:12345"
);
cont.add_processing_node("192.168.1.11
", 12345
);
cont.add_processing_node("192.168.1.11
:12345"
);
cont.add_processing_node("192.168.1.12
", 12345
);
cont.add_processing_node("192.168.1.12
:12345"
);
matrix<double> w;
matrix<double> w;
oca solver;
oca solver;
cont(solver, w); // Run the optimization.
cont(solver, w); // Run the optimization.
...
@@ -183,17 +183,29 @@ namespace dlib
...
@@ -183,17 +183,29 @@ namespace dlib
!*/
!*/
void
add_processing_node
(
void
add_processing_node
(
const
std
::
string
&
ip
,
const
network_address
&
addr
unsigned
short
port
);
);
/*!
/*!
requires
- addr.port != 0
ensures
ensures
- if (this
port and ip have
n't already been added) then
- if (this
address has
n't already been added) then
- #get_num_processing_nodes() == get_num_processing_nodes() + 1
- #get_num_processing_nodes() == get_num_processing_nodes() + 1
- When operator() is invoked to solve the structural svm problem
- When operator() is invoked to solve the structural svm problem this
this object will connect to the svm_struct_processing_node located
object will connect to the svm_struct_processing_node located at the
at the given IP address and port number and will include it in the
given network address and will include it in the distributed
distributed optimization.
optimization.
!*/
void
add_processing_node
(
const
std
::
string
&
ip_or_hostname
,
unsigned
short
port
);
/*!
requires
- port != 0
ensures
- invokes: add_processing_node(network_address(ip_or_hostname, port))
!*/
!*/
unsigned
long
get_num_processing_nodes
(
unsigned
long
get_num_processing_nodes
(
...
...
dlib/test/svm_struct.cpp
View file @
4f411d5a
...
@@ -212,7 +212,7 @@ namespace
...
@@ -212,7 +212,7 @@ namespace
if
(
verbose
)
if
(
verbose
)
controller
.
be_verbose
();
controller
.
be_verbose
();
controller
.
add_processing_node
(
"127.0.0.1"
,
12345
);
controller
.
add_processing_node
(
"127.0.0.1"
,
12345
);
controller
.
add_processing_node
(
"
127.0.0.1"
,
12346
);
controller
.
add_processing_node
(
"
localhost:12346"
);
svm_objective
=
controller
(
solver
,
weights
);
svm_objective
=
controller
(
solver
,
weights
);
...
...
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