The NumPy for Elm

566 views
Skip to first unread message

Francisco Ramos

unread,
Oct 31, 2017, 2:43:19 PM10/31/17
to elm-dev
Today I'm releasing NumElm, another small contribution to the Open Source, Frontend and Elm community. NumElm is inspired by NumPy, the fundamental package for scientific computing with Python. NumElm is the first step in this ambitious idea of mine of building a Machine Learning package for Elm. Still a long way to go, but I'm full of enthusiasm. I'm convinced about the potential of both worlds together, Elm language and Machine Learning. https://github.com/jscriptcoder/numelm

Evan Czaplicki

unread,
Oct 31, 2017, 2:52:16 PM10/31/17
to elm-dev
Thanks for sharing here!

I read through the readme and noticed it uses kernel code. I have a few requests about that:
  1. What features would you need to get the performance you are looking for? Lower-level arrays that have terrible update perf?
  2. Would you mind removing the links that explains the details of native code? That is all going to change, and I do not believe it pushes the ecosystem in a good direction.
Point (1) is interesting because the new Array implementation in core uses a lower-level representation of JS arrays that may be helpful. Rather than just going forth and implicitly promoting the use of alternate package download mechanisms, I think it'd be better to coordinate and see if there is some other path.

As a side note, why would a machine learning API in Elm would look anything like a C or Python API? Wouldn't the overlap just be data structures that are used? What does that have to do with NumPy? These are the things that are unclear to me based on my limited knowledge of all these domains.

On Tue, Oct 31, 2017 at 2:42 AM, Francisco Ramos <jscrip...@gmail.com> wrote:
Today I'm releasing NumElm, another small contribution to the Open Source, Frontend and Elm community. NumElm is inspired by NumPy, the fundamental package for scientific computing with Python. NumElm is the first step in this ambitious idea of mine of building a Machine Learning package for Elm. Still a long way to go, but I'm full of enthusiasm. I'm convinced about the potential of both worlds together, Elm language and Machine Learning. https://github.com/jscriptcoder/numelm

--
You received this message because you are subscribed to the Google Groups "elm-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to elm-dev+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/elm-dev/8fd30e26-bdf7-4751-8f54-4caf5e153b20%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Evan Czaplicki

unread,
Oct 31, 2017, 2:55:13 PM10/31/17
to elm-dev
Also, I hope "Lower-level arrays that have terrible update perf?" does not sound passive aggressive! That was the shortest technical description I could think of! Basically, I mean arbitrarily sized immutable arrays without any cleverness like in Array, implying that an update would be O(n) in the size because it requires a full copy. Sorry that that came through in a messy way!

Point is, if we know more about your particular technical needs, they can probably be addressed more directly with official support.

Francisco Ramos

unread,
Nov 1, 2017, 1:33:41 PM11/1/17
to elm...@googlegroups.com
Hi Evan,

thanks a lot for the feedback. Highly appreciated. Let me answer those points you mentioned:

1. Yes, I was actually thinking about those low-level arrays, TypedArray. I'm investigatin all possible solutions though. Also looking at https://deeplearnjs.org/ and see how it's using WebGL textures for hardware-accelarated operations... The core of NumElm is the NdArray, where you can pull out views without copying the underlying elements, therefore O(1). Important operations such as transposing, flipping, slicing, etc... can be made also in constant time. I'm starting a new project "elm-ndarray" using the Array.elm as a buffer. Then I'll come back to the community with performance tests and see what are the suggestions.

2. I've already removed the links about Native modules. Just for the record, I do agree with the policy about Native modules. I understand if this was allowed, Elm language would become the messy and full of runtime errors. Besides the fact it might one day compiled into something else.

Answering your questions: "why would a machine learning API in Elm would look anything like a C or Python API]?". There is no other reason but because I learnt Machine Learning using NumPy, which is the library to go in Python for scientific computing, used in many Machine and Deep Learning frameworks, and I simply used it as a guide. I'm trying to implement the necessary API to be able to cover most of the ML algorithms.

Thanks,
Fran

To unsubscribe from this group and stop receiving emails from it, send an email to elm-dev+u...@googlegroups.com.

--
You received this message because you are subscribed to the Google Groups "elm-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to elm-dev+u...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/elm-dev/CAF7GuPEpQPAK7EduOP-sFVsMMu6vziN66s_kjpwG8QG89ng3TA%40mail.gmail.com.

Evan Czaplicki

unread,
Nov 1, 2017, 1:46:34 PM11/1/17
to elm-dev
My first big recommendation is to check out machine learning APIs in Haskell and OCaml to see how they do it. I think it's better to work from (machine learning => Elm) rather than (NumPy in Elm => machine learning like Python)

And definitely keep this mailing list updated on what you learn and your technical needs! Folks like @unsoundscapes work on Elm's WebGL bindings, and getting more control over textures and buffers is something that'd be good in that area too. If you both need it, that makes it a stronger proposal with clearer use cases.

My second big recommendation is to think of this as a project to learn what operations are needed on lower-level data structures. In other words, communicating the technical needs to core folks should take priority to making a library for everyone to use. Unfortunately, Elm does not have the features to support such a library today, so it is necessarily blocked on data structures. (I personally think getting feedback from a small group is the better path anyway. This is actually the path that WebGL took in the pipeline to getting compiler support. Great communication and collaboration!)

On Wed, Nov 1, 2017 at 3:57 AM, Francisco Ramos <jscrip...@gmail.com> wrote:
Hi Evan,

thanks a lot for the feedback. Highly appreciated. Let me answer those points you mentioned:

1. Yes, I was actually thinking about those low-level arrays, TypedArray. I'm investigatin all possible solutions though. Also looking at https://deeplearnjs.org/ and see how it's using WebGL textures for hardware-accelarated operations... The core of NumElm is the NdArray, where you can pull out views without copying the underlying elements, therefore O(1). Important operations such as transposing, flipping, slicing, etc... can be made also in constant time. I'm starting a new project "elm-ndarray" using the Array.elm as a buffer. Then I'll come back to the community with performance tests and see what are the suggestions.

2. I've already removed the links about Native modules. Just for the record, I do agree with the policy about Native modules. I understand if this was allowed, Elm language would become the messy and full of runtime errors. Besides the fact it might one day compiled into something else.

Answering your questions: "why would a machine learning API in Elm would look anything like a C or Python API]?". There is no other reason but because I learnt Machine Learning using NumPy, which is the library to go in Python for scientific computing, used in many Machine and Deep Learning frameworks, and I simply used it as a guide. I'm trying to implement the necessary API to be able to cover most of the ML algorithms.

Thanks,
Fran

On Tue, Oct 31, 2017 at 7:55 PM Evan Czaplicki <eva...@gmail.com> wrote:
Also, I hope "Lower-level arrays that have terrible update perf?" does not sound passive aggressive! That was the shortest technical description I could think of! Basically, I mean arbitrarily sized immutable arrays without any cleverness like in Array, implying that an update would be O(n) in the size because it requires a full copy. Sorry that that came through in a messy way!

Point is, if we know more about your particular technical needs, they can probably be addressed more directly with official support.
On Tue, Oct 31, 2017 at 11:51 AM, Evan Czaplicki <eva...@gmail.com> wrote:
Thanks for sharing here!

I read through the readme and noticed it uses kernel code. I have a few requests about that:
  1. What features would you need to get the performance you are looking for? Lower-level arrays that have terrible update perf?
  2. Would you mind removing the links that explains the details of native code? That is all going to change, and I do not believe it pushes the ecosystem in a good direction.
Point (1) is interesting because the new Array implementation in core uses a lower-level representation of JS arrays that may be helpful. Rather than just going forth and implicitly promoting the use of alternate package download mechanisms, I think it'd be better to coordinate and see if there is some other path.

As a side note, why would a machine learning API in Elm would look anything like a C or Python API? Wouldn't the overlap just be data structures that are used? What does that have to do with NumPy? These are the things that are unclear to me based on my limited knowledge of all these domains.
On Tue, Oct 31, 2017 at 2:42 AM, Francisco Ramos <jscrip...@gmail.com> wrote:
Today I'm releasing NumElm, another small contribution to the Open Source, Frontend and Elm community. NumElm is inspired by NumPy, the fundamental package for scientific computing with Python. NumElm is the first step in this ambitious idea of mine of building a Machine Learning package for Elm. Still a long way to go, but I'm full of enthusiasm. I'm convinced about the potential of both worlds together, Elm language and Machine Learning. https://github.com/jscriptcoder/numelm

--
You received this message because you are subscribed to the Google Groups "elm-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to elm-dev+unsubscribe@googlegroups.com.

--
You received this message because you are subscribed to the Google Groups "elm-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to elm-dev+unsubscribe@googlegroups.com.

--
You received this message because you are subscribed to the Google Groups "elm-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to elm-dev+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/elm-dev/CAGd6hffa%2B%3Do8VeO1-2qWy_dTcN%3DAi2V6pLDsTMSRfteLpHFT%2BA%40mail.gmail.com.

Francisco Ramos

unread,
Nov 2, 2017, 2:33:09 PM11/2/17
to elm...@googlegroups.com
Thanks for the tip. It didn't occur to me to look into ML or Linear Algebra packages in Haskell. I'll also try to focus more in ML => Elm instead of trying to "mimic" the Python approach.
I'll keep this list updated with my progress.

Thanks,
Fran

To unsubscribe from this group and stop receiving emails from it, send an email to elm-dev+u...@googlegroups.com.

--
You received this message because you are subscribed to the Google Groups "elm-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to elm-dev+u...@googlegroups.com.

--
You received this message because you are subscribed to the Google Groups "elm-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to elm-dev+u...@googlegroups.com.
--
You received this message because you are subscribed to the Google Groups "elm-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to elm-dev+u...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/elm-dev/CAF7GuPF7e7SY4VoXGfyWGAJbKMswoLvZ08O8Y_srZ7FuGQcfFQ%40mail.gmail.com.
Reply all
Reply to author
Forward
0 new messages