12 ms·
Does anyone else think that C++ makes more sense for ML work than Python? I'd been thinking so for years. Both for deployment/performance and data wrangling pur
by dynamite-ready 5y ago
Does anyone else think that C++ makes more sense for ML work than Python? I'd been thinking so for years. Both for deployment/performance and data wrangling purposes.
- whimsicalism 5y agoIn general, I think languages with static typing are preferable. C++ seems ideal for me right now because it is the only other language with a somewhat mature stack (perhaps Julia as well, but I haven't played too much around with that).
- eigenspace 5y agoJulia is dynamically typed FYI. However, I find that usually when people say they want a statically typed language, they don't actually want static typing (which is just a restriction of language semantics), but instead they want a language with a powerful type system that does work for them. In this case, julia absolutely is worth checking out. It does static analysis on it's intermediate representation to automatically identify and isolate statically inferrable regions of programs and then stitches them together if it ever encounters any dynamism. Julia's type system is extremely powerful and expressive and can do a lot of things that are incredibly difficult in fully static languages precisely because it does allow dynamism.
- codebolt 5y agoAbsolutely. In 2010 I used FANN for my Msc thesis research, and found it pretty easy to make my own little training sim for stock price data on top of it. Haven't done any ML work since, but I always scratched my head over how Python became the most popular language for this domain.
- person_of_color 5y agostock price ml? why aren’t you rich?
- dynamite-ready 5y agoWho says they're not...
- teruakohatu 5y agoTake a look at Julia's Flux.jl. It has a really nice API and is quite intuitive to use at a low level, and has higher level components as well. Julia has a fast maturing data wrangling super-project (Queryverse).
- dynamite-ready 5y agoI'm guessing you'd have (slightly) fewer deployment options with Julia though.
- mpfundstein 5y agoyes. especially with AI on the edge.
- antpls 5y agoIn my opinion, no, it makes no sense to write ML in C++ : - Python allows for higher level description of algorithms, which means researchers can focus more on the ML stuff and less on low level details. - There is no performance gain in going from Python to C++, because in both cases the models are compiled to specific binary formats to be executed on dedicated hardwares. TensorFlow enables accelerators not only for training, but also for data transformations and preprocessing.
- v8dev123 5y agoYou will see Modern C++ more like Python these days. It has really neat stuff. A comment is not enough to describe this.
- beltsazar 5y ago> There is no performance gain in going from Python to C++ The backend of TF/PyTorch is written in C++ anyway, so the more complex the model, the less time it needs to spend in the glue code (frontend) that is written in Python. Therefore, rewriting complex models in full C++, for example by using TF/PyTorch C++ API, probably won't much improve the performance. In this paper the author rewrites some ML models in Rust using tch-rs (Rust binding for PyTorch C++ API) and finds the performance not that much better (even some models perform worse): https://www.aclweb.org/anthology/2020.nlposs-1.4/ https://www.aclweb.org/anthology/2020.nlposs-1.4/
- flemishgun 5y ago100% agree, and there are a number of efforts in the space. mlpack (https://www.github.com/mlpack/mlpack/ https://www.github.com/mlpack/mlpack/), Shogun (https://www.shogun-toolbox.org/ https://www.shogun-toolbox.org/), and Shark (https://www.shark-ml.org/ https://www.shark-ml.org/) are three that have been around for over a decade now. They're a little niche because C++ is not that popular for data science, but they are generally pretty fast (especially mlpack, which focuses on speed).
- deleted 5y ago[deleted]