to_numpy with Mojo 24.5
I try to convert the
to_numpy
method from the Mojo 24.4 based KMeans tutorial https://www.modular.com/blog/fast-k-means-clustering-in-mojo-guide-to-porting-python-to-mojo-for-accelerated-k-means-clustering to Mojo 24.5 but get the following error:
The orginal method is implemented as follows:
I replaced DTypePointer[dtype]
with UnsafePointer[Scalar[dtype]]
Any advice highly appreciated 😉Modular: Fast⚡k-means clustering in Mojo🔥: a guide to porting Pytho...
There are several clustering algorithms, but k-means — the algorithm we're going to implement from scratch in Python and Mojo🔥 in this blog post — is one of the most popular due to its simplicity and ease of implementation.
6 Replies
I think I have been there too. Does the following example from the MAX repo help as a reference?
https://github.com/modularml/max/blob/434daac5b52226d8c7ea024d08df127af5fce9dd/examples/serve/openclip-mojo-onnx/python_utils.mojo#L61
GitHub
max/examples/serve/openclip-mojo-onnx/python_utils.mojo at 434daac5...
A collection of sample programs, notebooks, and tools which highlight the power of the MAX Platform - modularml/max
Just to be clear, you updated
DTypePointer
to UnsafePointer
(due to deprecation) and got the above error? @Shashank PYou can check mine, it works: https://github.com/yetalit/Mojmelo/blob/main/mojmelo/utils/Matrix.mojo
GitHub
Mojmelo/mojmelo/utils/Matrix.mojo at main · yetalit/Mojmelo
Machine Learning algorithms in pure Mojo 🔥. Contribute to yetalit/Mojmelo development by creating an account on GitHub.
875 th line
thanks @TilliFe , @Darin Simmons and @DobyDabaDu - quite some other 24.4 -> 24.5 issues in the project i am working on so I cant check what works right now but will post here once it's done .... Thanks again 🙏
I ended up using @DobyDabaDu implementation which works like a charm. Thanks again for the all the feedback :mojo:
Glad it worked❤️