Coder Social home page Coder Social logo

k-means's Introduction

⤴️ ⤴️ k-means

license

This repository contains code referenced in my blog post Exploring k-means in Python, C++ and CUDA, where I implement k-means in a variety of platforms. In this post I show how CUDA implementations of k-means can outperform scikit-learn and scipy in performance by a factor of 72 and 90, respectively.

The code is not particularly tidy, but gives an idea of how to implement k-means efficiently on a GPU.

Contents

  • python/ contains Python code for k-means using scikit-learn, scipy and a roll-it-yourself implementation.
  • cpp/ contains C++ implementations of k-means, including one using Eigen.
  • cuda/ holds all CUDA implementations.
  • data/ has some toy data with 100 and 100k datapoints in five clusters as well as a script to generate more.

Authors

Peter Goldsborough + cat ❤️

k-means's People

Contributors

goldsborough avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

k-means's Issues

Bug?

Hi,

There are some code in kmeans cuda fast version might be bug.

if (index < k) {
const int count = max(1, counts[index]);
means_x[index] = new_sum_x[index] / count;
means_y[index] = new_sum_y[index] / count;
new_sum_y[index] = 0;
new_sum_x[index] = 0;
counts[index] = 0;
}

I think new_sum_x[index] should be replaced by shared_data at some index.
Btw, shouldn't counts do the parallel reduction on shared memory?

thanks.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.