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.

PyTorch vs. TensorFlow in 2022

350 pointsby SleekEagleover 3 years ago

22 comments

tehf0xover 3 years ago
As a researcher in RL &amp; ML in a big industry lab, I would say most of my colleagues are moving to JAX [<a href="https:&#x2F;&#x2F;github.com&#x2F;google&#x2F;jax" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;google&#x2F;jax</a>], which this article kind of ignores. JAX is XLA-accelerated NumPy, it&#x27;s cool beyond just machine learning, but only provides low-level linear algebra abstractions. However you can put something like Haiku [<a href="https:&#x2F;&#x2F;github.com&#x2F;deepmind&#x2F;dm-haiku" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;deepmind&#x2F;dm-haiku</a>] or Flax [<a href="https:&#x2F;&#x2F;github.com&#x2F;google&#x2F;flax" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;google&#x2F;flax</a>] on top of it and get what the cool kids are using :)
评论 #29554023 未加载
评论 #29555767 未加载
评论 #29554620 未加载
评论 #29559004 未加载
评论 #29554720 未加载
评论 #29556061 未加载
评论 #29561389 未加载
评论 #29557261 未加载
评论 #29556168 未加载
评论 #29554200 未加载
评论 #29553748 未加载
评论 #29566788 未加载
评论 #29563889 未加载
评论 #29557979 未加载
tadeeganover 3 years ago
Tensorflow is just such a classic clusterfuck google project. V2 had huge breaking changes (reminiscent of angular) and tons of the apis are clunky and don’t work well together. There are like 3 different ways to save a model. It’s almost like a bunch of teams built features with no oversight.<p>I’m pretty sure tf is considered in maintenance mode within google as Brain and the tf creators themselves have moved to Jax. I do think Google learned a lot from tensorflow and am excited to see Jax pan out.<p>Pytorch is a pleasure to debug. I think pytorch jit could close the deployment gap.
评论 #29554819 未加载
评论 #29554834 未加载
评论 #29562325 未加载
评论 #29556717 未加载
评论 #29554628 未加载
axegon_over 3 years ago
At one point I lost interest in both and ML&#x2F;AI in general. I think eventually I got frustrated with the insane amounts of abuses for marketing purposes and never truly delivering what was promised(I know, I know, fake it till you make it). For better or worse far too few managed to make it, so most stuck with faking. I think I lost interest completely around 2019. But even back then they were starting to seem like twins - practically identical with some minor but sometimes subtle differences. Looking at random sections of the documentation, all you gotta do is ignore the semantics...<p>&gt; tf.nn.conv2d(input, filters, strides, padding, data_format=&#x27;NHWC&#x27;, dilations=None, name=None)<p>&gt; torch.nn.functional.conv2d(input, weight, bias=None, stride=1, padding=0, dilation=1, groups=1)
评论 #29554661 未加载
评论 #29554888 未加载
评论 #29554509 未加载
评论 #29556533 未加载
cfcf14over 3 years ago
For any kind of research or experimental work, I cannot imagine using anything other than PyTorch, with the caveat that I do think JAX is extremely impressive and I&#x27;ve been meaning to learn more about it for a while.<p>Even though I&#x27;ve been working with Tensorflow for a few years now and I feel like I do understand the API pretty well, to some extent that just means I&#x27;m _really_ good at navigating the documentation, because there&#x27;s no way to intuit the way things work. And I still run into bizarre performance issues when profiling graphs pretty much all the time. Some ops are just inefficient - oh but it was fixed in 2.x.yy! Oh but then it broke again in 2.x.yy+1! Sigh.<p>However - and I know this is a bit of a tired trope, but any kind of industrial deployment is just vastly, vastly easier with Tensorflow. I&#x27;m currently working with ultra-low-latency model development targeting a Tensorflow-Lite inference engine (C-API, wrapped via Rust) and it&#x27;s just incredibly easy. With some elbow grease and willingness to dive into low level TF-Lite optimisations, one can see end to end model inference times in the order of 10-100us for simple models (say, a fully connected dnn with a few million parameters), and between 100us-1ms for fairly complex models utilising contemporary architectures in computer vision or NLP. Memory overhead and control over inference computation semantics are easy.<p>As a nice cherry on top, we can take the same Tensorflow SavedModels that get compiled to TF-Lite files and instead compile them to tensorflow-js for easy web deployment, which is a great portability upside.<p>However, I know there&#x27;s some incredible progress being made on what one might call &#x27;environmental agnostic computational graph ILs&#x27; (on second thought, let&#x27;s not keep that name) which should open up more options for inference engines and graph optimisations (operator fusion, rollups, hardware dependant stuff, etc).<p>Overall I feel like things have been continuously getting better for the last 5 years or so. I&#x27;m pleased to see so many more options.
评论 #29554093 未加载
评论 #29562194 未加载
nmcaover 3 years ago
This article says that Google and DeepMind research use TF - but they don&#x27;t. DeepMind use JAX almost exclusively, and many brain researchers use JAX too.<p>ML eng is my area of expertise, and I would advise strongly against tensorflow.
评论 #29560834 未加载
lvl100over 3 years ago
I just want an alternative to CUDA. I am sick of Nvidia’s monopoly in this space.
评论 #29558889 未加载
评论 #29556394 未加载
dash2over 3 years ago
&quot;PyTorch and TensorFlow are far and away the two most popular Deep Learning frameworks today. The debate over whether PyTorch or TensorFlow is superior is a longstanding point of contentious debate, with each camp having its share of fervent supporters.<p>Both PyTorch and TensorFlow...&quot;<p>Can an article really be any good if it starts off with such obvious SEO spam?
评论 #29554683 未加载
评论 #29558493 未加载
johnnyApplePRNGover 3 years ago
I always look to Google trends when trying to decide upon which framework to use.<p>PyTorch just recently took the lead. [0] So if I were having to choose between learning the either of them, I would go with PyTorch.<p>[0] <a href="https:&#x2F;&#x2F;trends.google.com&#x2F;trends&#x2F;explore?date=all&amp;q=tensorflow,pytorch" rel="nofollow">https:&#x2F;&#x2F;trends.google.com&#x2F;trends&#x2F;explore?date=all&amp;q=tensorfl...</a>
g42gregoryover 3 years ago
As a practitioner, I feel that oftentimes you are extending, fine tuning somebody else’s code or pre-trained models (DeepMind’s for example). This means that you should be able to work on whatever the platform this code came with. Basically, you should be able to work with JAX, TF or PyTorch with equal ease.
评论 #29557040 未加载
bjourneover 3 years ago
Great article. While I only had time to skim the article, I&#x27;ll still offer my uninformed opinions. :) None of the hw I own is particularly great. I don&#x27;t even own a decent GPU. But I don&#x27;t need to because you can train your models for FREE on Google Colab&#x27;s TPUs and GPUs. PyTorch&#x27;s TPU support is still not that great while TensorFlow&#x27;s is maturing. It&#x27;s obviously a priority for Google to make TensorFlow work well on their own hardware.<p>So for me the choice is TF 2 because I can train models 5-10x faster using Google&#x27;s TPUs than if I had used PyTorch. I know the PyTorch developers are working on TPU support but last I checked (this spring) it wasn&#x27;t there yet and I wasn&#x27;t able to make it work well on Google Colab.
synergy20over 3 years ago
As a layman in ML, I thought PyTorch is more(or only) geared towards researchers while Tensorflow has its problems it is the _only_ one that provides a commercial solutions that you can deploy, is this still true?<p>JAX is totally new to me, is this Google&#x27;s new Tensorflow in the future?
lettergramover 3 years ago
The thing is, tensorflow has more ability to run cross platform.<p>I help maintain <a href="https:&#x2F;&#x2F;github.com&#x2F;capitalone&#x2F;DataProfiler" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;capitalone&#x2F;DataProfiler</a><p>Our sensitive data detection library is exported to iOS, android, and Java; in addition to Python. We also run distributed and federated use cases with custom layers. All of which are improved in tensorflow.<p>That said, I’d use pytorch if I could. Simply put, it has a better user experience.
评论 #29554992 未加载
评论 #29555355 未加载
astroalexover 3 years ago
No mention of Google MediaPipe (<a href="https:&#x2F;&#x2F;mediapipe.dev&#x2F;" rel="nofollow">https:&#x2F;&#x2F;mediapipe.dev&#x2F;</a>), which is a mobile&#x2F;edge framework for deploying TFLite models. MediaPipe has the advantage of letting you stitch together multiple models, transformations, and heuristics into a higher level computational graph. I&#x27;m not aware of any equivalent for PyTorch, although PyTorch Live seems like baby steps in that direction.
评论 #29555656 未加载
Kalanosover 3 years ago
Post doesn&#x27;t talk about the actual libraries, just the ecosystems surrounding them.<p>TF has more layer types, parallelizes better, is easier to assemble w keras, and you don&#x27;t have to recreate the optimizer when loading from disk. pytorch doesn&#x27;t have metrics out of the box. TF all the way.<p>github.com&#x2F;aiqc&#x2F;aiqc
评论 #29705684 未加载
评论 #29554031 未加载
评论 #29554604 未加载
d4rkp4tternover 3 years ago
Does TF have any advantages in terms of ease of acceleration (training and inference) with multiple GPUs?<p>Our pipeline is all PyTorch Lightning — this made development easy but we have been having numerous issues trying to leverage multiple GPUs (this is for sequence models), keep getting strange errors.
strzibnyover 3 years ago
This looks like a good comparison. A lot of comparisons online are way superficial or plain wrong.
评论 #29555313 未加载
cinntaileover 3 years ago
In TF you don&#x27;t have to manually calculate the number of parameters of a fully connected layer. That&#x27;s kind of nice. I don&#x27;t really understand why PyTorch requires me to do that. Surely this can be infered from the previous layer.
评论 #29556942 未加载
评论 #29555323 未加载
bigbillheckover 3 years ago
I started with tensorflow back in 2017 or so, then in my current job I am touching a lot of pytorch, and as such I say a pox on both their houses.<p>But keras is OK and I greatly appreciate that you can (sometimes) serialize everything to hdf5.
minimaxirover 3 years ago
At this point, there&#x27;s so much conceptual and syntactical overlap between the two frameworks that there isn&#x27;t a &quot;winner.&quot; Like most DS&#x2F;ML tools, use which one fits your use case.
评论 #29553689 未加载
303bookwormover 3 years ago
Mumble grumble <i>Keras</i>.<p>(&quot;Shakes old man&#x27;s fist at sky, and at people who seems to enjoy boilerplate code too much&quot;)
评论 #29554513 未加载
streamofdigitsover 3 years ago
in the fullness of time JAX might prove to be more important than either. don&#x27;t give people fish, teach them how to catch fish and all that...
justinlloydover 3 years ago
I will preface with the statement that my knowledge may be slightly out of date as I don&#x27;t keep up on every nuanced change.<p>I use PyTorch and TensorFlow, and the article is spot-on in regard to &quot;mystery operations that take a long time&quot; with no real rhyme or reason behind them with regard to TensorFlow. That said, on the whole, I skew more towards TensorFlow because it is generally easier to reason about the graph and how it connects. I also find the models that are available to usually be more refined, robust and useful straight out of the box.<p>With PyTorch I am usually fighting a slew of version incompatibilities in the API between even more point releases. The models often feel more slap-dash thrown together, research like projects or toy projects, and whilst the article points out the number of papers that use PyTorch far exceeds those that use TensorFlow, and the number of models for PyTorch dwarfs that of TensorFlow, there isn&#x27;t a lot of quality in the quantity. &quot;90% of everything is crap.&quot; Theodore Sturgeon. And that goes double for PyTorch models. A lot of the models, and even some datasets, just feel like throwaway projects that someone put up online.<p>If you are on macOS or Linux and using Python, PyTorch works fine, but don&#x27;t step outside of that boundary. PyTorch and TensorFlow work with other operating systems, and other languages besides Python, but working with anything but Python when using PyTorch is a painful process fraught with pain. And yes, I expect someone to drop in and say &quot;but what about this C++ framework?&quot; or &quot;I use language X with PyTorch every day and it works fine for me!&quot; But again, the point stands, anything but Python with PyTorch is painful. The support of other languages for TensorFlow is far richer and far better.<p>And I will preface this with, &quot;my knowledge may be out of date&quot; but I&#x27;ve also noticed the type of models and project code available for TensorFlow and PyTorch diverge wildly once you get outside of the toy projects. If you are doing computer vision, especially with video and people, and you are not working on the most simplest of pose analysis, TensorFlow offers a lot more options of stuff straight out of the box. PyTorch has some good projects and models, but they are mostly of the Mickey Mouse hobby stuff, or an abstract research project that isn&#x27;t very robust or immediately deployable.<p>I use TensorFlow in my day-to-day job. All that said, I like PyTorch for its quirkiness, its rapid prototyping, its popularity, and the fact that so many people are trying out a lot of different things, even if they don&#x27;t work particularly well. I use PyTorch in almost all of my personal research projects.<p>I expect in the future for PyTorch to get more stable and more deployable and have better tools, if it can move slightly away from the &quot;research tool&quot; phase it is currently in. I expect Google to do the usual Google-Fuck-Up and completely change TF for the worse, break compatibility (TF1 to TF2) or just abandon the project entirely and move on to the next new shiny.