TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

Ask HN: Whats the best way to learn C++ for Deep learning?

73 pointsby wpmoradiover 6 years ago

16 comments

krat0sprakharover 6 years ago
I&#x27;m not sure how C++ for DL is different from regular C++ so take my advice with a grain of salt.<p>I took a class under Bjarne Stroustrup and he highly recommended Tour of C++ [0] as the best way to learn modern C++ for someone who already has some programming experience. That and of course, Effective C++[1] by Scott Meyers.<p>[0] - <a href="https:&#x2F;&#x2F;www.amazon.com&#x2F;Tour-C-Depth&#x2F;dp&#x2F;0321958314" rel="nofollow">https:&#x2F;&#x2F;www.amazon.com&#x2F;Tour-C-Depth&#x2F;dp&#x2F;0321958314</a><p>[1] - <a href="https:&#x2F;&#x2F;www.amazon.com&#x2F;Effective-Specific-Improve-Programs-Designs&#x2F;dp&#x2F;0321334876" rel="nofollow">https:&#x2F;&#x2F;www.amazon.com&#x2F;Effective-Specific-Improve-Programs-D...</a>
评论 #18170076 未加载
评论 #18170215 未加载
siekmanjover 6 years ago
I think python is generally used for AI and data science stuff, so you&#x27;d probably be better off learning that.<p>That said, I think one of the best ways to learn how to do something is dive right into it. I&#x27;m currently in the process of writing a deep learning library in C: <a href="https:&#x2F;&#x2F;github.com&#x2F;siekmanj&#x2F;sieknet" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;siekmanj&#x2F;sieknet</a><p>So if you&#x27;re dead set on C++, I&#x27;d say the best way is to try to build something cool right off the bat.
评论 #18169457 未加载
评论 #18172409 未加载
spottover 6 years ago
What is your reason for learning &quot;C++ for deep learning&quot;?<p>This will kind of define <i>how</i> to go about doing it.<p>I can think of a few different reasons you might want to do this:<p>* You DL code in another framework is slow, and you have some custom C++ you want to write to speed it up. For this, you probably want to learn both high performance C++ and&#x2F;or CUDA kernel development. You can probably avoid diving completely into C++, and just call a couple of optimized routines from python (and whatever other deep learning framework you are using in python). In this case, it might be worth looking into Tensor Comprehensions.<p>* You are taking someone elses DL algorithm and moving it to C++. In this case, you still don&#x27;t need to be diving too much into C++, Ideally, you probably want to use something like ONNX and Caffe, and then call into them with some python wrapper. If you want the whole thing to be in C++, then you are still going to use something like ONNX and Caffe, but you will be writing mostly application code to support it.<p>* You want to help with the development of Pytorch, Tensorflow, Caffe or anther deep learning framework. In this case, you need to know CUDA kernel development, performant C++ idioms, and good C++ application development idioms.<p>These are pretty different flavors of C++, which makes it hard to give you a good answer.
评论 #18171046 未加载
valedraover 6 years ago
You can look at examples from DyNet (<a href="https:&#x2F;&#x2F;dynet.readthedocs.io&#x2F;en&#x2F;latest&#x2F;cpp_basic_tutorial.html" rel="nofollow">https:&#x2F;&#x2F;dynet.readthedocs.io&#x2F;en&#x2F;latest&#x2F;cpp_basic_tutorial.ht...</a>) or the C++ Pytorch bindings (<a href="https:&#x2F;&#x2F;pytorch.org&#x2F;cppdocs&#x2F;" rel="nofollow">https:&#x2F;&#x2F;pytorch.org&#x2F;cppdocs&#x2F;</a>). I would strongly recommend python though, as most deep learning work is done with it.
评论 #18169778 未加载
make3over 6 years ago
With 1.0, PyTorch now has an official legit C++ frontend: <a href="https:&#x2F;&#x2F;pytorch.org&#x2F;cppdocs&#x2F;frontend.html" rel="nofollow">https:&#x2F;&#x2F;pytorch.org&#x2F;cppdocs&#x2F;frontend.html</a><p>PyTorch was apparently used in ~43% of the ICLR papers (a big prestigious deep learning conference) (<a href="https:&#x2F;&#x2F;www.reddit.com&#x2F;r&#x2F;MachineLearning&#x2F;comments&#x2F;9kys38&#x2F;r_frameworks_mentioned_iclr_20182019_tensorflow&#x2F;" rel="nofollow">https:&#x2F;&#x2F;www.reddit.com&#x2F;r&#x2F;MachineLearning&#x2F;comments&#x2F;9kys38&#x2F;r_f...</a>) and it&#x27;s market share is growing at an incredible pace. I would expect it to beat Tensorflow in popularity at least for research very soon.<p>That&#x27;s definitely where I would start if I absolutely had to do deep learning in C++. Otherwise I would do Python, which is likely used by 95% + of the research field.
madenineover 6 years ago
Just like if you were going to learn Python for Deep Learning, you&#x27;re going to need 3 things:<p>1. Understanding of Deep Learning<p>2. General familiarity with the language<p>3. Understanding of packages&#x2F;tools that will help you accomplish your goals. If this were python we&#x27;d be talking Numpy&#x2F;TensorFlow&#x2F;PyTorch&#x2F;Keras&#x2F;etc.<p>We&#x27;re talking C++, I&#x27;m guessing you&#x27;ll want to work with less abstraction than TF and the like, so BLAS, LAPACK, and maybe the whole CUDA family (CUDA, cuBLAS, cuDNN, etc).<p>Otherwise, TensorFlow, Caffe, CNTK, and other popular deep learning frameworks are available for C++, even though they might be better known and more heavily used in other languages.
gmiller123456over 6 years ago
If you look into deep learning, I think you&#x27;ll quickly learn that the programming language doesn&#x27;t matter that much. I think a great place to start would be the &quot;Two Minute Papers&quot;[1] Youtube channel. A lot of what he presents there is deep learning material, with links to the actual papers and often the source code as well as a plain English explanation of what&#x27;s going on and why it&#x27;s important. After looking at the source code of a handful, I think you&#x27;ll realize that focusing on learning a single language won&#x27;t be of any use.<p>I think it&#x27;s also important to point out that it&#x27;s not a great way to ask for help without giving some details about your background and your motives. If you&#x27;ve been programming in any language for quite a while, you&#x27;ll need a completely different approach to &quot;learning C++ for deep learning&quot; than someone who&#x27;s never programmed before. Likewise, if your goal is to work in the industry producing cutting edge work, you&#x27;ll take a completely different approach than someone who just wants a rough understanding of the details just to satisfy your curiosity. So, without providing that context, you&#x27;re going to get answers that are all over the place, almost all of which will be useless to you.<p><a href="https:&#x2F;&#x2F;www.youtube.com&#x2F;channel&#x2F;UCbfYPyITQ-7l4upoX8nvctg" rel="nofollow">https:&#x2F;&#x2F;www.youtube.com&#x2F;channel&#x2F;UCbfYPyITQ-7l4upoX8nvctg</a>
mooneaterover 6 years ago
Might be 3 different skills here:<p>1) learn c++ 2) learn deep learning 3) learn c++ with deep learning: much easier once you have done 1) and 2)
评论 #18169926 未加载
评论 #18169674 未加载
ergodicover 6 years ago
If you are looking for a computational graph toolkit that is based on clean C++ go for Dynet.<p>It is very complete. Similar to pytorch (which borrowed some ideas from Dynet) and backed up by top academia (not big tech, hence its lower profile). It has a python wrapper as well, as everything nowadays.<p>If you are into deep learning for sequence to sequence (machine translation) Marian is also C++ centered. Fastest MT around. Complete (transformer and the like), extendable. Not that reading friendly from what I have heard.<p>Disclaimer: Python type of guy here.
gaiusover 6 years ago
Plenty of examples with CNTK <a href="https:&#x2F;&#x2F;docs.microsoft.com&#x2F;en-us&#x2F;cognitive-toolkit&#x2F;cntk-library-api" rel="nofollow">https:&#x2F;&#x2F;docs.microsoft.com&#x2F;en-us&#x2F;cognitive-toolkit&#x2F;cntk-libr...</a><p>Also Nvidia have a course <a href="https:&#x2F;&#x2F;courses.nvidia.com&#x2F;courses&#x2F;course-v1:DLI+C-AC-01+V1&#x2F;about" rel="nofollow">https:&#x2F;&#x2F;courses.nvidia.com&#x2F;courses&#x2F;course-v1:DLI+C-AC-01+V1&#x2F;...</a><p>But I am also curious why... this is deep-end stuff if you’ll forgive the pun. Why not start with Keras and only dip into the C++ if you need to?
jahewsonover 6 years ago
DL libraries are pretty complex and sparsely documented which can make for a painful learning experience, even if you already know C++. Maybe go and learn some graphics programming with C++. You’ll encounter plenty of matrix manipulation, shaders, OpenGL and the like, and there are plenty of really good learning resources and the immediate visual feedback makes for a compelling experience. Then you can return to DL and understand where things are coming from.<p>Make sure you learn how to use a debugger. You’ll need it.
skinner_over 6 years ago
Besides the already-mentioned pytorch and tensorflow bindings, <a href="http:&#x2F;&#x2F;dlib.net&#x2F;" rel="nofollow">http:&#x2F;&#x2F;dlib.net&#x2F;</a> is an option if C++ is really a hard requirement. It is opinionated and incomplete, basically being a one-man-show, but it has some weird-but-cool ideas like each neural network topology having its own template type.
jason_slackover 6 years ago
I guess for me, having been using c++ as my preferred language for 25 years I just now read api&#x27;s. When new C++ features are added I get to know then by practicing using them in small programs then into production code.<p>Stroustrup and Meyers are the two most well known names. I buy all their books and I read them and practice all exercises and problems if the book has them.
mothsonaslothover 6 years ago
Since half the people are ignoring the question and chipping in their own language recommendations. I will join the bandwagon.<p>Use Java and enjoy C++ like syntax with 80% equivalent performance (based on my experience)<p>Then try this library - <a href="https:&#x2F;&#x2F;deeplearning4j.org&#x2F;" rel="nofollow">https:&#x2F;&#x2F;deeplearning4j.org&#x2F;</a>
评论 #18175381 未加载
wpmoradiover 6 years ago
Or C++ for general software development purposes...
timwaaghover 6 years ago
Deep lesson: learn C#. decrement.