Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot create NeighborSearch with arma:fmat MatType #506

Closed
victor1234 opened this issue Jan 22, 2016 · 8 comments
Closed

Cannot create NeighborSearch with arma:fmat MatType #506

victor1234 opened this issue Jan 22, 2016 · 8 comments

Comments

@victor1234
Copy link

I cannot declare type:

using KnnModel = mlpack::neighbor::NeighborSearch<mlpack::neighbor::NearestNeighborSort,
                                                  mlpack::metric::ManhattanDistance,
                                                  arma::fmat,
                                                  mlpack::tree::KDTree>;

error:

/usr/include/mlpack/core/tree/hrectbound_impl.hpp:372:30: 
error: no matching function for call to 
‘arma::Col<double>::Col(const arma::Op<arma::subview<float>, arma::op_min>)’
   arma::vec mins(min(data, 1));

Is threre no implementation for float or I'm doing something wrong?

@victor1234 victor1234 changed the title Cannot create NeighborSearch for arma:fmat MatType Cannot create NeighborSearch with arma:fmat MatType Jan 22, 2016
@rcurtin
Copy link
Member

rcurtin commented Jan 25, 2016

Hi there,

It turns out that I never wrote a test for this use case, and fixing this will take some more work than I had anticipated. I think that when I allowed arbitrary MatType, I was thinking of arma::mat and arma::sp_mat, but definitely the other matrix types are useful too! (See also #290) I've started the work in 3561ad7, but there are lots of other pieces that need to come together. I'd like to hope I can have this done in a few weeks (or sooner).

@rcurtin rcurtin self-assigned this Jan 25, 2016
@rcurtin rcurtin added this to the mlpack 2.0.1 milestone Jan 25, 2016
@victor1234
Copy link
Author

I think you should note in library overview about incomplete float support. It was critical for me and I spent some time for library familiarization before know about it (API looks like very generic and I didn't expect it).

@rcurtin rcurtin modified the milestones: mlpack 2.0.2, mlpack 2.0.1 Feb 24, 2016
@versusvoid
Copy link

Similar problem in KMeans:

float mat[] = { 1, 2, 3, 4, 5, 6 };
const arma::fmat data(mat, 2, 3, false, true);

size_t number_of_clusters = 2;  

arma::Row<size_t> assignments(3);

arma::mat centroids(2, 3);

km::KMeans<mlpack::metric::EuclideanDistance, km::RandomPartition, 
           km::MaxVarianceNewCluster, km::NaiveKMeans, arma::fmat> k;

k.Cluster(data, number_of_clusters, assignments, centroids);
/usr/include/mlpack/methods/kmeans/kmeans_impl.hpp: In instantiation of ‘void mlpack::kmeans::KMeans<MetricType, InitialPartitionPolicy, EmptyClusterPolicy, LloydStepType, MatType>::Cluster(const MatType&, size_t, arma::Row<long unsigned int>&, arma::mat&, bool, bool) [with MetricType = mlpack::metric::LMetric<2, true>; InitialPartitionPolicy = mlpack::kmeans::RandomPartition; EmptyClusterPolicy = mlpack::kmeans::MaxVarianceNewCluster; LloydStepType = mlpack::kmeans::NaiveKMeans; MatType = arma::Mat<float>; size_t = long unsigned int; arma::mat = arma::Mat<double>]’:
test.cxx:44:65:   required from here
/usr/include/mlpack/methods/kmeans/kmeans_impl.hpp:239:37: error: no matching function for call to ‘arma::Col<double>::Col(const arma::subview_col<float>)’
       centroids.col(assignments[i]) += arma::vec(data.col(i));

@kartikdutt18
Copy link
Member

This issue still exists. @ojhalakshya and I are taking this up.

@ojhalakshya
Copy link
Contributor

Hey @rcurtin
I had been working on this issue for a while now, even after making a dozen of template changes I am not sure whether it is the right direction to move forward in.
I do have a branch for it currently, @kartikdutt18 has also made some changes there. If you see fit I can make a pr, or maybe you can first take a look at it.
Thanks.

@ojhalakshya
Copy link
Contributor

@rcurtin how must we proceed in this issue.
Thanks.

@rcurtin
Copy link
Member

rcurtin commented Apr 17, 2020

@ojhalakshya this is not an easy issue to resolve. :) It will require templating everything involved with NeighborSearch to accept different types of matrices. I'd suggest starting from the simple example posted in the original issue, and making that work. I think many of the things in the tree infrastructure are already templatized, so, there may not be much work left to do. Consider taking the test case DualTreeVsNaive1 from knn_test.cpp and adapting that to use arma::fmat instead of arma::mat; once that works correctly, we can probably call the issue solved. :)

@ojhalakshya
Copy link
Contributor

okay @rcurtin will see into these files, and try to make some things work out.
Will ping you if I need more info :)
Thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

6 participants