2
$\begingroup$

For Machine and Deep Learning purposes, is it recommended to simply use Python and the packages available for it, rather than coding it manually in C++?

I wished to do so for performance gains, but I am hearing that the Python packages are so well-optimized that they perform better than anything I could write in a short time in C++?

$\endgroup$
2
$\begingroup$

There's at least three considerations here:

  1. effort: unless what you do is extremely time consuming and computationally expensive, the effort to try to come up with a better implementation is usually not worth it, even if it is possible (i.e. you save some seconds, but spend days implementing)
    1. flexibility (closely related to effort): major libraries tend to have a lot of options implemented, so you can switch/change/experiment and do a lot of obvious things really easily without having to code anything extra
    2. futility: major libraries tend to be extremely well optimized and often may use some for of C or numba or some other mechanism to achieve fast computation in the background - e.g. fast execution may not help you, if you are not aware of various clever computational tricks (e.g. how to parameterize something, some numerical tricks like log_sum_exp etc.).

My default assumption is that it is usually not worth it.

When would I consider it:

  1. You would just have to program everything from scratch in python anyway.
  2. If you want to do something very non-standard for which there is only some really mediocre implementation
  3. You need some really specific narrow thing that is being slowed down by unnecessary overhead in the major library.
  4. What you will implement will compute away for many, many months or years (think SETI at home) and investing in a streamlined focussed implementation makes some weeks of programming time well worth it.
$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.