"src/array/cuda/spmm.hip" did not exist on "a7e941c379f0f9ab472c844b6a9f1d05d687b4e1"
Commit a5b2454c authored by Davis King's avatar Davis King
Browse files

Removed the dlib::sparse_vector namespace. I put everything from this

namespace into the normal dlib:: namespace so that code which works
with both sparse and dense vectors is more cohesive.
parent 2f2aecc9
......@@ -135,30 +135,30 @@ namespace
// Now test some of the sparse helper functions
DLIB_TEST(sparse_vector::max_index_plus_one(samples) == 2);
DLIB_TEST(sparse_vector::max_index_plus_one(samples[0]) == 2);
DLIB_TEST(max_index_plus_one(samples) == 2);
DLIB_TEST(max_index_plus_one(samples[0]) == 2);
matrix<double,3,1> m;
m = 1;
sparse_vector::add_to(m, samples[3]);
add_to(m, samples[3]);
DLIB_TEST(m(0) == 1 + samples[3][0].second);
DLIB_TEST(m(1) == 1 + samples[3][1].second);
DLIB_TEST(m(2) == 1);
m = 1;
sparse_vector::subtract_from(m, samples[3]);
subtract_from(m, samples[3]);
DLIB_TEST(m(0) == 1 - samples[3][0].second);
DLIB_TEST(m(1) == 1 - samples[3][1].second);
DLIB_TEST(m(2) == 1);
m = 1;
sparse_vector::add_to(m, samples[3], 2);
add_to(m, samples[3], 2);
DLIB_TEST(m(0) == 1 + 2*samples[3][0].second);
DLIB_TEST(m(1) == 1 + 2*samples[3][1].second);
DLIB_TEST(m(2) == 1);
m = 1;
sparse_vector::subtract_from(m, samples[3], 2);
subtract_from(m, samples[3], 2);
DLIB_TEST(m(0) == 1 - 2*samples[3][0].second);
DLIB_TEST(m(1) == 1 - 2*samples[3][1].second);
DLIB_TEST(m(2) == 1);
......@@ -227,7 +227,6 @@ namespace
sv[0] = 1;
sv[3] = 1;
using namespace sparse_vector;
DLIB_TEST(dot(sv,dv) == 5);
DLIB_TEST(dot(dv,sv) == 5);
......@@ -249,7 +248,6 @@ namespace
sv[0] = 1;
sv[3] = 1;
using namespace sparse_vector;
assign(dv2, dv);
......
......@@ -64,7 +64,7 @@ namespace
feature_vector_type& psi
) const
{
sparse_vector::assign(psi, samples[idx]);
assign(psi, samples[idx]);
// Add a constant -1 to account for the bias term.
psi.push_back(std::make_pair(dims-1,static_cast<scalar_type>(-1)));
......@@ -88,8 +88,6 @@ namespace
// LOSS(idx,y) + F(x,y). Note that y in this case is given by distinct_labels[i].
for (unsigned long i = 0; i < distinct_labels.size(); ++i)
{
using dlib::sparse_vector::dot;
using dlib::dot;
// Compute the F(x,y) part:
// perform: temp == dot(relevant part of current solution, samples[idx]) - current_bias
scalar_type temp = dot(rowm(current_solution, range(i*dims, (i+1)*dims-2)), samples[idx]) - current_solution((i+1)*dims-1);
......@@ -106,7 +104,7 @@ namespace
}
}
sparse_vector::assign(psi, samples[idx]);
assign(psi, samples[idx]);
// add a constant -1 to account for the bias term
psi.push_back(std::make_pair(dims-1,static_cast<scalar_type>(-1)));
......@@ -221,7 +219,7 @@ namespace
trained_function_type df;
const long dims = sparse_vector::max_index_plus_one(all_samples);
const long dims = max_index_plus_one(all_samples);
df.labels = select_all_distinct_labels(all_labels);
df.weights = colm(reshape(weights, df.labels.size(), dims+1), range(0,dims-1));
df.b = colm(reshape(weights, df.labels.size(), dims+1), dims);
......@@ -302,7 +300,7 @@ namespace
trained_function_type df;
const long dims = sparse_vector::max_index_plus_one(all_samples);
const long dims = max_index_plus_one(all_samples);
df.labels = select_all_distinct_labels(all_labels);
df.weights = colm(reshape(weights, df.labels.size(), dims+1), range(0,dims-1));
df.b = colm(reshape(weights, df.labels.size(), dims+1), dims);
......@@ -383,7 +381,7 @@ namespace
trained_function_type df;
const long dims = sparse_vector::max_index_plus_one(all_samples);
const long dims = max_index_plus_one(all_samples);
df.labels = select_all_distinct_labels(all_labels);
df.weights = colm(reshape(weights, df.labels.size(), dims+1), range(0,dims-1));
df.b = colm(reshape(weights, df.labels.size(), dims+1), dims);
......@@ -464,7 +462,7 @@ namespace
trained_function_type df;
const long dims = sparse_vector::max_index_plus_one(all_samples);
const long dims = max_index_plus_one(all_samples);
df.labels = select_all_distinct_labels(all_labels);
df.weights = colm(reshape(weights, df.labels.size(), dims+1), range(0,dims-1));
df.b = colm(reshape(weights, df.labels.size(), dims+1), dims);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment