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
d7df21a8
Commit
d7df21a8
authored
Dec 23, 2012
by
Davis King
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
switched examples over to the new mat() method.
parent
a5d30218
Show whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
15 additions
and
15 deletions
+15
-15
assignment_learning_ex.cpp
examples/assignment_learning_ex.cpp
+2
-2
custom_trainer_ex.cpp
examples/custom_trainer_ex.cpp
+2
-2
krr_classification_ex.cpp
examples/krr_classification_ex.cpp
+2
-2
matrix_expressions_ex.cpp
examples/matrix_expressions_ex.cpp
+1
-1
rank_features_ex.cpp
examples/rank_features_ex.cpp
+2
-2
sequence_labeler_ex.cpp
examples/sequence_labeler_ex.cpp
+4
-4
using_custom_kernels_ex.cpp
examples/using_custom_kernels_ex.cpp
+2
-2
No files found.
examples/assignment_learning_ex.cpp
View file @
d7df21a8
...
...
@@ -177,8 +177,8 @@ int main()
{
// Predict the assignments for the LHS and RHS in samples[i].
std
::
vector
<
long
>
predicted_assignments
=
assigner
(
samples
[
i
]);
cout
<<
"true labels: "
<<
trans
(
vector_to_matrix
(
labels
[
i
]));
cout
<<
"predicted labels: "
<<
trans
(
vector_to_matrix
(
predicted_assignments
))
<<
endl
;
cout
<<
"true labels: "
<<
trans
(
mat
(
labels
[
i
]));
cout
<<
"predicted labels: "
<<
trans
(
mat
(
predicted_assignments
))
<<
endl
;
}
// We can also use this tool to compute the percentage of assignments predicted correctly.
...
...
examples/custom_trainer_ex.cpp
View file @
d7df21a8
...
...
@@ -118,9 +118,9 @@ public:
}
// divide by number of +1 samples
positive_center
/=
sum
(
vector_to_matrix
(
labels
)
==
+
1
);
positive_center
/=
sum
(
mat
(
labels
)
==
+
1
);
// divide by number of -1 samples
negative_center
/=
sum
(
vector_to_matrix
(
labels
)
==
-
1
);
negative_center
/=
sum
(
mat
(
labels
)
==
-
1
);
custom_decision_function
df
;
df
.
positive_center
=
positive_center
;
...
...
examples/krr_classification_ex.cpp
View file @
d7df21a8
...
...
@@ -65,8 +65,8 @@ int main()
}
cout
<<
"samples generated: "
<<
samples
.
size
()
<<
endl
;
cout
<<
" number of +1 samples: "
<<
sum
(
vector_to_matrix
(
labels
)
>
0
)
<<
endl
;
cout
<<
" number of -1 samples: "
<<
sum
(
vector_to_matrix
(
labels
)
<
0
)
<<
endl
;
cout
<<
" number of +1 samples: "
<<
sum
(
mat
(
labels
)
>
0
)
<<
endl
;
cout
<<
" number of -1 samples: "
<<
sum
(
mat
(
labels
)
<
0
)
<<
endl
;
// Here we normalize all the samples by subtracting their mean and dividing by their standard deviation.
// This is generally a good idea since it often heads off numerical stability problems and also
...
...
examples/matrix_expressions_ex.cpp
View file @
d7df21a8
...
...
@@ -384,7 +384,7 @@ void custom_matrix_expressions_example(
As an aside, note that dlib contains functions equivalent to the ones we
defined above. They are:
- dlib::trans()
- dlib::
vector_to_matrix(
)
- dlib::
mat() (converts things into matrices
)
- operator+ (e.g. you can say my_mat + 1)
...
...
examples/rank_features_ex.cpp
View file @
d7df21a8
...
...
@@ -79,8 +79,8 @@ int main()
// Here we normalize all the samples by subtracting their mean and dividing by their standard deviation.
// This is generally a good idea since it often heads off numerical stability problems and also
// prevents one large feature from smothering others.
const
sample_type
m
(
mean
(
vector_to_matrix
(
samples
)));
// compute a mean vector
const
sample_type
sd
(
reciprocal
(
s
qrt
(
variance
(
vector_to_matrix
(
samples
)
))));
// compute a standard deviation vector
const
sample_type
m
(
mean
(
mat
(
samples
)));
// compute a mean vector
const
sample_type
sd
(
reciprocal
(
s
tddev
(
mat
(
samples
))));
// compute a standard deviation vector
// now normalize each sample
for
(
unsigned
long
i
=
0
;
i
<
samples
.
size
();
++
i
)
samples
[
i
]
=
pointwise_multiply
(
samples
[
i
]
-
m
,
sd
);
...
...
examples/sequence_labeler_ex.cpp
View file @
d7df21a8
...
...
@@ -228,8 +228,8 @@ int main()
// print out some of the randomly sampled sequences
for
(
int
i
=
0
;
i
<
10
;
++
i
)
{
cout
<<
"hidden states: "
<<
trans
(
vector_to_matrix
(
labels
[
i
]));
cout
<<
"observed states: "
<<
trans
(
vector_to_matrix
(
samples
[
i
]));
cout
<<
"hidden states: "
<<
trans
(
mat
(
labels
[
i
]));
cout
<<
"observed states: "
<<
trans
(
mat
(
samples
[
i
]));
cout
<<
"******************************"
<<
endl
;
}
...
...
@@ -251,8 +251,8 @@ int main()
// Test the learned labeler on one of the training samples. In this
// case it will give the correct sequence of labels.
std
::
vector
<
unsigned
long
>
predicted_labels
=
labeler
(
samples
[
0
]);
cout
<<
"true hidden states: "
<<
trans
(
vector_to_matrix
(
labels
[
0
]));
cout
<<
"predicted hidden states: "
<<
trans
(
vector_to_matrix
(
predicted_labels
));
cout
<<
"true hidden states: "
<<
trans
(
mat
(
labels
[
0
]));
cout
<<
"predicted hidden states: "
<<
trans
(
mat
(
predicted_labels
));
...
...
examples/using_custom_kernels_ex.cpp
View file @
d7df21a8
...
...
@@ -160,8 +160,8 @@ int main()
}
}
cout
<<
"samples generated: "
<<
samples
.
size
()
<<
endl
;
cout
<<
" number of +1 samples: "
<<
sum
(
vector_to_matrix
(
labels
)
>
0
)
<<
endl
;
cout
<<
" number of -1 samples: "
<<
sum
(
vector_to_matrix
(
labels
)
<
0
)
<<
endl
;
cout
<<
" number of +1 samples: "
<<
sum
(
mat
(
labels
)
>
0
)
<<
endl
;
cout
<<
" number of -1 samples: "
<<
sum
(
mat
(
labels
)
<
0
)
<<
endl
;
// A valid kernel must always give rise to kernel matrices which are symmetric
...
...
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