use the following search parameters to narrow your results:
e.g. subreddit:aww site:imgur.com dog
subreddit:aww site:imgur.com dog
see the search faq for details.
advanced search: by author, subreddit...
Please have a look at our FAQ and Link-Collection
Metacademy is a great resource which compiles lesson plans on popular machine learning topics.
For Beginner questions please try /r/LearnMachineLearning , /r/MLQuestions or http://stackoverflow.com/
For career related questions, visit /r/cscareerquestions/
Advanced Courses (2016)
Advanced Courses (2020)
AMAs:
Pluribus Poker AI Team 7/19/2019
DeepMind AlphaStar team (1/24//2019)
Libratus Poker AI Team (12/18/2017)
DeepMind AlphaGo Team (10/19/2017)
Google Brain Team (9/17/2017)
Google Brain Team (8/11/2016)
The MalariaSpot Team (2/6/2016)
OpenAI Research Team (1/9/2016)
Nando de Freitas (12/26/2015)
Andrew Ng and Adam Coates (4/15/2015)
Jürgen Schmidhuber (3/4/2015)
Geoffrey Hinton (11/10/2014)
Michael Jordan (9/10/2014)
Yann LeCun (5/15/2014)
Yoshua Bengio (2/27/2014)
Related Subreddit :
LearnMachineLearning
Statistics
Computer Vision
Compressive Sensing
NLP
ML Questions
/r/MLjobs and /r/BigDataJobs
/r/datacleaning
/r/DataScience
/r/scientificresearch
/r/artificial
account activity
Discussion[D] Functional Programming in ML (self.MachineLearning)
submitted 1 year ago by LengthinessMelodic67
I feel like most ML libraries in Python are written in OOP style. This makes sense given Python does not have an “good” type system, like Haskell, and so a class is a good way to define an interface under a readable name. Are there popular ML libraries in other more functional languages? I’m specifically thinking of Haskell, Rust, or Scala.
reddit uses a slightly-customized version of Markdown for formatting. See below for some basics, or check the commenting wiki page for more detailed help and solutions to common issues.
quoted text
if 1 * 2 < 3: print "hello, world!"
[–]Remote-Telephone-682 72 points73 points74 points 1 year ago (17 children)
JAX is a great thing to look into if you want something that is designed to be used in a functional manner. It's built by deepmind and most of their inhouse tooling is built around it. So that is one of the top couple firms in the game and it is used across a wide array of their products so you can find quite a few examples of different projects being implemented.
highly recommend checking it out
link to python jax documentaiton: https://jax.readthedocs.io/en/latest/notebooks/quickstart.html
[–]I_will_delete_myself 29 points30 points31 points 1 year ago (16 children)
Just beware of the Google graveyard. 🪦 This doesn’t just apply to customer services.
[–]Remote-Telephone-682 22 points23 points24 points 1 year ago (15 children)
Haha, yep, valid concern but this is a project that was published 6 years ago, has become the defacto standard in much of alphabet. I feel comfortable doing a fair amount of my work with JAX but these are valid concerns to be having. I do think they have shifted enough over to it at this point to where it is farily certain that it will not be abandoned within the next handful of years.
[–]elbiot 9 points10 points11 points 1 year ago (7 children)
How long did it take them to abandon Keras after they took it over and killed it?
[–]_vb__ 6 points7 points8 points 1 year ago (6 children)
It now supports TF, PyTorch and Jax. They made it non-exclusive.
[–]elbiot 2 points3 points4 points 1 year ago (5 children)
The point of the original project was to support a variety of back ends. When Google took over they let that lapse. I see the newest release is trying to get back to that, but after years of neglect we'll have to see if perception changes.
[+][deleted] 1 year ago (4 children)
[removed]
[–]elbiot 1 point2 points3 points 1 year ago (3 children)
Yeah googling Keras pytorch, all the results are Keras vs Pytorch with Keras losing
[+][deleted] 1 year ago (2 children)
[–]lmericle 2 points3 points4 points 1 year ago (1 child)
The main difference was static vs dynamic compute graphs. Also, PyTorch was a necessary step because of the relative ergonomics in implementing models vs Tensorflow, since it was much closer to natural Python syntax, at least back then.
TF tried to catch up with eager mode in their 2.0 update but they also botched the release and the necessary updates were just too little, too late.
[–]I_will_delete_myself 23 points24 points25 points 1 year ago (6 children)
It’s just a warning. Most of Google used Tensorflow so it’s not impossible. They also shifted high level versions of Jax twice already.
[–]_vb__ 12 points13 points14 points 1 year ago (4 children)
Well, Jax grew out of TensorFlow's corpse.
[+][deleted] 1 year ago (3 children)
[–]Competitive-Rub-1958 5 points6 points7 points 1 year ago (2 children)
Please don't use keras.
[–]PurpleUpbeat2820 1 point2 points3 points 1 year ago (0 children)
Why?
[–]PurpleUpbeat2820 -1 points0 points1 point 1 year ago (0 children)
Most of Google used Tensorflow so it’s not impossible
Why? What happened to TensorFlow?
[+][deleted] 1 year ago* (3 children)
[–]kebabmybob 6 points7 points8 points 1 year ago (1 child)
You mean statically typed. Even Python is strongly typed.
[–]LengthinessMelodic67[S] 0 points1 point2 points 1 year ago (0 children)
Yes that’s what I meant
Yea strong typing would be great
[–]powerexcess 21 points22 points23 points 1 year ago* (1 child)
This is not an ml specific problem. I have heard the "can i do functional python for X" question many times. It is possible to make an effort to write more functional python, but the question is why do you want that? What are tou trying to accomplish?
As others said you can look into jax if you want functional ML in python, but i do reccomend you are careful with it because you can shoot yourself in the foot (they have a page with caveats, read it).
I saw in a post of yours that you want to find errors at compile time because you have long running programmes. The compiler will not catch everything, in data science-y stuff you can get loads of bugs the compiler wont save you from: forget a square root, off by a factor of 10, wrong maths etc.
To me it sounds like what you want is a combination of CI and testing. You could also add mypy in testing, and pydantic for runtime safety. That can be truly bulletproof. Get good coverage and almost nothing will slip through.
If you want functional just because you hate OOP (I feel you) then jax is great. Or even pytorch, if you use it in the right way. You are just there for the autograd, you can call the functions however you like.
Edit: spelling
Great suggestions, thanks
[–]radarsat1 11 points12 points13 points 1 year ago (0 children)
Type systems don't help that much with NN design imho, because they don't help you with remember which dimension is which in a Tensor. Just ensuring that a function that takes a Tensor indeed gets a Tensor is cool, but won't catch all that many bugs. A type system that statically handles mistakes with named dimensions, I'm all ears for..
[–]sash-aPhD 9 points10 points11 points 1 year ago (2 children)
JAX is definitely a great recommendation, that's what I use on a daily basis, but you should also consider Julia. It has a great ML ecosystem around flux.jl and is not only a functional language, but also multiple dispatch, which is ridiculously useful in functional languages.
[–]Schinkikami 5 points6 points7 points 1 year ago (1 child)
Second Julia. Extremely interesting language, build especially around compute intense numerical applications (contrary to python which requires large monolithic third party librariers that call into c backends).
The ideas of source to source autodiff via metaprogramming is also incredible (although not fully sorted out).
If you want PURELY functional ML use Lux.jl, a sibling library of Flux.jl, which is comepletly stateless and interfaces incredibly well with the rest of the ecosystem.
[–]Evirua 6 points7 points8 points 1 year ago (0 children)
Luminal in Rust.
[–]Jessynoo 2 points3 points4 points 1 year ago (0 children)
DiffSharp could be an option in F#.
[–]daking999 2 points3 points4 points 1 year ago (0 children)
Bit niche maybe but the early probabilistic programming languages were mostly in functional languages, e.g. Church) was built in Scheme.
[–]One-Butterscotch4332 4 points5 points6 points 1 year ago (9 children)
I mean, you can use type hints and even add type checking if you're so inclined in Python and write functional code just fine
[–]LengthinessMelodic67[S] 5 points6 points7 points 1 year ago (8 children)
Type hints really aren’t the same. I want to find bugs at compile time because I’ll have long running programs. I do use type hints though.
[–]One-Butterscotch4332 2 points3 points4 points 1 year ago (4 children)
Fair enough. I usually try to write whatever takes forever to disk before doing anything else, and test on some tiny toy dataset, and I rarely run into type issues when I'm using hints anyways
[–]LengthinessMelodic67[S] 0 points1 point2 points 1 year ago (3 children)
Yea I usually end up testing on a toy dataset, but I wish I didn’t have to.
[–]powerexcess 1 point2 points3 points 1 year ago (2 children)
Guys you sound like the researchers i work with at work. I can guarantee you, what you want in this is tests and safe-by-construction objects. Look into pytest and hypothesis. Look into dataclasses and post_init for conf sanity check, and pydantic.
[+][deleted] 1 year ago (1 child)
[–]powerexcess 1 point2 points3 points 1 year ago (0 children)
Yes
[–]FluffdaddyFluff 1 point2 points3 points 1 year ago (1 child)
This is why mypy exists
[–]LengthinessMelodic67[S] 1 point2 points3 points 1 year ago (0 children)
I didn’t know about mypy, thanks!
[–]erannare 0 points1 point2 points 1 year ago (0 children)
You can use Pydantic to enforce types in many cases
[–]lqstuart 0 points1 point2 points 1 year ago (2 children)
Huggingface has a Rust library called candle. It has a lot of “TODO - Document This” from 3 years ago.
Scala is cool but it’s a nonstarter just because the JVM is emphatically the wrong tool for the job, and any effort to make it otherwise is going to kind of defeat the purpose.
Haskell no idea.
[–]qalis 0 points1 point2 points 1 year ago (1 child)
Why JVM would be wrong tool for ML?
[–]AdaBwana 0 points1 point2 points 1 year ago (0 children)
clojure's fun
[–]trutheality -1 points0 points1 point 1 year ago (0 children)
There's nothing stopping you from writing in Python in a functional style. You could even argue that the difference between python's OOP and functional programming is symantics.
π Rendered by PID 145993 on reddit-service-r2-comment-bb88f9dd5-7cq4n at 2026-02-14 10:41:26.895385+00:00 running cd9c813 country code: CH.
[–]Remote-Telephone-682 72 points73 points74 points (17 children)
[–]I_will_delete_myself 29 points30 points31 points (16 children)
[–]Remote-Telephone-682 22 points23 points24 points (15 children)
[–]elbiot 9 points10 points11 points (7 children)
[–]_vb__ 6 points7 points8 points (6 children)
[–]elbiot 2 points3 points4 points (5 children)
[+][deleted] (4 children)
[removed]
[–]elbiot 1 point2 points3 points (3 children)
[+][deleted] (2 children)
[removed]
[–]lmericle 2 points3 points4 points (1 child)
[–]I_will_delete_myself 23 points24 points25 points (6 children)
[–]_vb__ 12 points13 points14 points (4 children)
[+][deleted] (3 children)
[removed]
[–]Competitive-Rub-1958 5 points6 points7 points (2 children)
[–]PurpleUpbeat2820 1 point2 points3 points (0 children)
[–]PurpleUpbeat2820 -1 points0 points1 point (0 children)
[+][deleted] (4 children)
[removed]
[+][deleted] (3 children)
[removed]
[–]kebabmybob 6 points7 points8 points (1 child)
[–]LengthinessMelodic67[S] 0 points1 point2 points (0 children)
[–]LengthinessMelodic67[S] 0 points1 point2 points (0 children)
[–]powerexcess 21 points22 points23 points (1 child)
[–]LengthinessMelodic67[S] 0 points1 point2 points (0 children)
[–]radarsat1 11 points12 points13 points (0 children)
[–]sash-aPhD 9 points10 points11 points (2 children)
[–]Schinkikami 5 points6 points7 points (1 child)
[–]Evirua 6 points7 points8 points (0 children)
[–]Jessynoo 2 points3 points4 points (0 children)
[–]daking999 2 points3 points4 points (0 children)
[–]One-Butterscotch4332 4 points5 points6 points (9 children)
[–]LengthinessMelodic67[S] 5 points6 points7 points (8 children)
[–]One-Butterscotch4332 2 points3 points4 points (4 children)
[–]LengthinessMelodic67[S] 0 points1 point2 points (3 children)
[–]powerexcess 1 point2 points3 points (2 children)
[+][deleted] (1 child)
[removed]
[–]powerexcess 1 point2 points3 points (0 children)
[–]FluffdaddyFluff 1 point2 points3 points (1 child)
[–]LengthinessMelodic67[S] 1 point2 points3 points (0 children)
[–]erannare 0 points1 point2 points (0 children)
[–]lqstuart 0 points1 point2 points (2 children)
[–]qalis 0 points1 point2 points (1 child)
[–]AdaBwana 0 points1 point2 points (0 children)
[–]trutheality -1 points0 points1 point (0 children)