I built the same model with TensorFlow and PyTorch | Which Framework is better?

Поділитися
Вставка
  • Опубліковано 18 гру 2024

КОМЕНТАРІ • 104

  • @lukewood5751
    @lukewood5751 2 роки тому +238

    Not using a validation split is actually a pretty big difference. For some additional perspective, adding additional training examples is typically more beneficial than model architecture differences. You shouldn't use the split in TensorFlow if you want to make a comparison like this; even if you cite this reason.

    • @gowiththeflo59
      @gowiththeflo59 2 роки тому +12

      Yea ditto this is actually a huge difference in the comparison

    • @aliawad2244
      @aliawad2244 Рік тому +1

      exactly! I wonder why he did this since I was really intrigued to see the results :(

    • @loftyTHEOWNER
      @loftyTHEOWNER Рік тому +1

      I don't see why the results should be different between the 2 if everything else is the same. After all, the math to compute the weight update is the same. I was much more interested in the speed comparison. But even for that, I think it would be better to try some larger models and run them multiple times using state of the art features, instead of just simple examples...

    • @williamsorenson1525
      @williamsorenson1525 8 місяців тому

      @@loftyTHEOWNER Overfitting. The tensorflow model could learn the training data really well, but not be so good at the test data. If the validation data had a picture of a red car and there was no red car in the training data, then the model will get confused, as it may have overfitted and relied heavily on the color of the car. In general, you almost always want a validation split, as it catches the problem of overfitting early on.

    • @g.4279
      @g.4279 7 місяців тому

      He didn't even control the order of the images being used for training, it is very different. You need averages and retraining to quantify performance.

  • @DHAtEnclaveForensics
    @DHAtEnclaveForensics Рік тому +26

    The results are also different because the initialization of the weights and biases is random. Unless you make them identical you can never expect to get the same results.

  • @ai_minds_
    @ai_minds_ 2 роки тому +35

    If you used all data for train torch model, there is no point to compare metrics
    + you should define random seed as well

  • @ogrp5777
    @ogrp5777 2 роки тому +58

    Saying that PyTorch is better than TF by just looking at the results of one run? Deep learning models have a random component … so this result is completely lead by chance. When I see the title of the video, I thought the video was about doing a real comparison regarding usability, memory and GPU consumption, etc

    • @phoenix212
      @phoenix212 Рік тому +4

      I don't think this video meant to be a benchmark of the two frameworks, he literally said "performance wise both frameworks are on the same level"

    • @maxxel_
      @maxxel_ Рік тому +1

      i think you missed the point my guy

    • @yudzu8820
      @yudzu8820 9 місяців тому +1

      It looks like this video was meant for newbies, who dont even know basics yet or even what cuda is. So no wonder, that this is only "oh look, how code looks"

  • @cristianpadurariu
    @cristianpadurariu 2 роки тому +70

    what about weight initialization? .... that could affect the performance pretty dramatically in some cases

    • @matteolacki4533
      @matteolacki4533 2 роки тому +13

      Precisely, running TF twice as well one will not end up with the same result unless one sets some fixed random seed.

  • @StaMariaRock
    @StaMariaRock Рік тому +38

    As a begginner, Tensorflow feels way easier, pytorch looks and feels like some deep engineering, I guess I might have to learn both. But I still prefer Tensorflow, feels like it available for everyone

    • @arnavpurushotamcomputerscience
      @arnavpurushotamcomputerscience Рік тому +4

      yeah even i started off with tensorflow seeing how easy to use it was, but most research projects are implemented in pytorch. Since i had to analyze much open source research code during my projects, it was critical to know pytorch as well in addition to tensorflow

    • @loftyTHEOWNER
      @loftyTHEOWNER Рік тому +4

      Now that ChatGPT can write all the code you need, I feel there is not much difference anymore. But for more complex stuff, I feel PyTorch become easier, because you don't need to go and modify the classes with some weird inheritances. I've just wrote some custom classes for learning rate schedule and early stopping in PyTorch and it completely felt like normal Python...

  • @prathameshdinkar2966
    @prathameshdinkar2966 Рік тому +4

    Nice video! Just want to add at 2:09, there are 3 methods to create the tf model. I think you missed to mention functional API which is intermediate between Sequential and Subclassing

  • @rahulprasad2318
    @rahulprasad2318 2 роки тому +112

    Comparing accuracy doesn't make sense here. 1st, initial weights are random. 2. Pytorch was trained on full train dataset. If anything this just shows tf is much much faster to get a model ready. Pytorch is only good if you are getting paid for finding new stuff.

    • @aminuroseline9904
      @aminuroseline9904 2 роки тому +13

      He said the result could be skewed, it's not "could be" it was actually skewed, imagine doing this in type of comparison in a normal research!!

    • @patloeber
      @patloeber  2 роки тому +13

      yes, I mentioned that skills could be skewed and performance is on the same level. Showing the accuracy should mainly demonstrate that the loss and accuracy values lie in the same range :)

    • @dinoscheidt
      @dinoscheidt 2 роки тому +7

      @@rogerab1792 and create a bunch of bugs along the way? PyTorch and Tensorflow are heavily tested and verified tools. Trusting you in your academic reasoning AND your engineering skills? Just no

    • @clairelesaffre249
      @clairelesaffre249 Рік тому

      ​@@rogerab1792 I don't think it's VERY useful, I think it's fun. It's like recoding libc and C++ containers. They already exist but we recode it to prove something for ourselves. Not useful.

    • @fcbarca4949
      @fcbarca4949 Рік тому

      ​@patloeber Hi sir, can you kindly provide that pytorch and tensorflow code links in description?

  • @cloud_1992
    @cloud_1992 2 роки тому +8

    What about training and evaluation time? Which has less value?

    • @christianherrera4729
      @christianherrera4729 2 роки тому

      I was thinking the same thing.

    • @robosergTV
      @robosergTV 2 роки тому +1

      use ONNX format for serving, then it doesnt matter if its TF or PyTorch

  • @robc1775
    @robc1775 2 роки тому +2

    A UA-cam comment section with well thought out intelligent comments, making valid arguments in favor and opposition! 🤯 Great input worth pondering!

  • @peilanhsu
    @peilanhsu 2 місяці тому

    Thank you SO MUCH for making this video! I'm transitioning from TF to PyTorch and REALLY needed a "same model, both frameworks" video like this one!

  • @nicklam3594
    @nicklam3594 2 роки тому +25

    No JIT/ mixed precision optimizations? Comparing the accuracy of the same model on different frameworks and not understanding that the difference is due to the randomness of the initialization? Weird video.

    • @lupsik1
      @lupsik1 2 роки тому +1

      Using all data without a validation split was the biggest factor in the difference.
      Given enough time and a simple task, those networks are very likely to still end up near the same local minima. But i agree that initializing all w&b to the same values would be cooler.
      Kind of a pity, i really wish i could see the experiment properly repeated

  • @Imboredas
    @Imboredas 2 роки тому +12

    As far as I’m concerned, the research community heavily favors pytorch these days, at least for the field I’m in (NLP). Mostly because of huggingface and fairseq I think 😂
    Also, with tensorflow and Keras, even with the eager mode enabled, the error messages are not as helpful as pytorch. Another thing I like about torch is that everything inherits from nn.module, unlike in keras, where model and layer are two separate classes.

    • @harrytsang1501
      @harrytsang1501 2 роки тому +4

      TF is simpler for building well-researched models, and PyTorch has better data loader and lower level controls for the cutting edge.
      In my experience because torch tensor can be manually managed to be stored on CPU or co-processors, it can be significantly faster than TF when managed correctly. Newer versions of Nvidia’s VideoProcessingFramework even provides bindings for direct conversion between video and PyTorch Tensors on the GPU so working with video is real time

    • @doords
      @doords 2 роки тому

      Do you find pytorch to better for NLP projects? I got in with Pytorch because our engineers from Stanford are taught in it.

    • @Imboredas
      @Imboredas 2 роки тому

      @@doords I would say so, just because most of the recent work that publish their code in open source are in PyTorch, except for google's papers (for obvious reasons).
      It's similar to recommending react. It's not that it is better than its competitors dramatically, but just that it is more popular in the community now, which means you can get more help, more established codebase / libraries, etc.

    • @doords
      @doords 2 роки тому

      @@Imboredas That is good know. By the way which online communities do you recommend in case we run into problems working on NLP projects.

  • @maxxel_
    @maxxel_ Рік тому +1

    great vid, was cool for me to see how initializing and training a model in pytorch looks like

  • @wyctorfogos232
    @wyctorfogos232 2 роки тому +6

    Great video ! But only one observation: you must compare the models'creation using the Tensorflow in it's Advanced mode, because Pytorch ia based on Oriented object.

  • @parttimelarry
    @parttimelarry 2 роки тому +20

    Great video and editing, you covered a lot of ground in 13 minutes.

  • @zoneofflow5556
    @zoneofflow5556 2 роки тому +27

    Why didn't you include pytorch-lightning, as you have included keras for tensorflow? It would have been a better comparison, and in my usage lightning overthrows keras in terms of ease of usage.
    In this video, you did basically keras vs pytorch.

    • @CppExpedition
      @CppExpedition 2 роки тому +2

      He can't cover in depth everything in one video! Please be patient.
      Which framework do you like the most?
      i have the feeling that every single one is wrong

    • @VegetableJuiceFTW
      @VegetableJuiceFTW 2 роки тому +1

      agree 100%

  • @md.arrahmandip7638
    @md.arrahmandip7638 10 місяців тому

    Hello there, how to setup both pytorch and tensorflow in same machine using one cuda toolkit? Or in different environment maintaining same cuda toolkit?
    Thank you.

  • @bediosoro7786
    @bediosoro7786 2 роки тому +3

    I think that you should have use model sequential in pytorch or use gratienttape approach in tensorflow for better comparison.

  • @RohanPaul-AI
    @RohanPaul-AI 2 роки тому +1

    Nice and clean presentation in 13 mints. Great video, Thank you.

  • @juanete69
    @juanete69 2 роки тому

    Can I use "crossentropy" as a metric as we also do for the loss?

  • @paul_devos
    @paul_devos 2 роки тому +8

    Wow. Great video doing the side by side. Momentum and adoption seems to favor PyTorch and in general, many FB frameworks over Google frameworks. I could definitely see where if you're a very good Python developer (or want to be), PyTorch would be a very "easy" choice. TensorFlow seems very easy for the "incremental" command workflows that many Data Scientists do especially if they aren't really good with OOP.
    So in essence, TensorFlow feels a little bit like R for Stats, a "researcher first" tool... you get a ton of stuff just included, whereas with Python, you have to build and customize all your outputs, which feels more SWE driven than Researcher/Academic driven, e.g. like R.

  • @Trepetsky
    @Trepetsky 10 місяців тому

    Jax, very flexible, but also fast, faster than PyTorch. And you can still run on TPU. Yes, now support for TPU has been added to PyTorch, but it was recently done, I tried it, it's still raw.

  • @sumitmore6824
    @sumitmore6824 Рік тому

    Which software should I use for both ??

  • @sergyyoubi3739
    @sergyyoubi3739 2 роки тому +9

    For a JavaScript Developer like me, Tensorflow/Keras is easier to learn bcz its syntax is almost the same as JS

    • @Bengt.Lueers
      @Bengt.Lueers 2 роки тому +9

      You would be writing TensorFlow-style Python as if it were JavaScript?! Please don't.

    • @dezaku6612
      @dezaku6612 2 роки тому

      @@Bengt.Lueers there is tensorflow.js I think that's what he meant

  • @datascience3008
    @datascience3008 2 роки тому

    In pytorch
    In the fully connected layer
    Why was it multiplied by 4*4

  • @amrohendawi6007
    @amrohendawi6007 2 роки тому +4

    Comparing two frameworks on different levels of abstraction is not a fair comparison.

  • @karinwiberg2223
    @karinwiberg2223 2 роки тому +4

    By another UA-cam video I learned that Pytorch is more commonly used for Computer Vision and NPL than for "traditional" data (numbers, categories etc). What do you say about using Pytorch with traditional data?

  • @cipherxen2
    @cipherxen2 Рік тому +3

    On one hand python programmers want to write less code, but here they want to write more code. How?

  • @LocNguyen-lb7ii
    @LocNguyen-lb7ii 2 роки тому +17

    I dont think performance test base on acc and loss is some what appropriate, because you didn't set a seed for python or random package so the initial state of neuron weight will be different, anw I still think this is a great video, thanks for your effort.

    • @iworeushankaonce
      @iworeushankaonce 2 роки тому +3

      Agree. CV, and averaging across multiple runs could've solved this issue.

  • @Ahmed-ym7zi
    @Ahmed-ym7zi Рік тому

    Where can I see the full codes?

  • @magmyr
    @magmyr Рік тому

    The answer, like with many other topics in computer science: it depends

  • @shivamroy1775
    @shivamroy1775 2 роки тому +2

    Very informative and crisp video. Love the effort put into it. Keep up the good work !

  • @utubesuxman
    @utubesuxman Рік тому

    Super helpful information and very clearly communicated

  • @farleylai1102
    @farleylai1102 2 роки тому

    All the randomness needs to be under control: seeds for python and CUDA, weight initialization, optimizer and etc.
    How about another head to head benchmark on Apple M1 Pro/Max?

  • @jeremyheng8573
    @jeremyheng8573 2 роки тому +1

    Very good explanation

  • @codingcrashkurse6429
    @codingcrashkurse6429 2 роки тому +2

    I think both are pretty good ;-)

  • @monisprabu1174
    @monisprabu1174 2 роки тому

    Thank you very much for this comparison !!!

  • @djangoworldwide7925
    @djangoworldwide7925 2 роки тому +2

    Does anyone even use R in the real world? It has a TF option as well

  • @davidtindell950
    @davidtindell950 2 роки тому

    Good overview. TU.
    I employ both frameworks and often prototype on Apple Silicon as well as
    Intel ++ NVidea ...
    . . .

  • @bladesskate3954
    @bladesskate3954 Рік тому

    Which is better for a beginner?

    • @DrunkenUFOPilot
      @DrunkenUFOPilot 7 місяців тому +1

      Flip a coin and go with it either way. Both have plenty of tutorials, Q&A forums, etc. and you can't go wrong with the one you choose. Just stick with it for long enough you can 'think' in it and have done a small project or demo worthy of showing others before diving into the other.

  • @ChrisHalden007
    @ChrisHalden007 2 роки тому

    Great video. Thanks!

  • @harshraj2575
    @harshraj2575 2 роки тому +2

    With my little experience (mostly with torch), my opinion is biased but I felt torch is much more user friendly while debugging while tensorflow can give you hypertension at times.

  • @eranfeit
    @eranfeit 2 роки тому

    Very nice video. Thanks

  • @md.musfiqurrahaman8612
    @md.musfiqurrahaman8612 2 роки тому +2

    Thanks man for this amazing tutorial...

  • @CppExpedition
    @CppExpedition 2 роки тому

    Possible the most relevant decision we do without knowing! ^_^

  • @Aishwarya_Varma21
    @Aishwarya_Varma21 2 роки тому +2

    Hi,
    Aishwarya here. I was looking around for data scientists and found your profile.
    Currently I am working on a 3D CT reconstruction project deploying tensorflow in it. I am facing a bit of errors in the code and unable to arrive at a result. Could you please help me with this rn if possible ?

  • @supervince110
    @supervince110 2 роки тому +2

    Tf was super confusing when they introduced 2.0

  • @CppExpedition
    @CppExpedition 2 роки тому

    love learning by doing! love this channel!

  • @dreamphoenix
    @dreamphoenix 2 роки тому

    Thank you.

  • @suleimankhader
    @suleimankhader 2 роки тому

    what about MLflow?

  • @bananaatss
    @bananaatss 2 роки тому

    It could be the random seed

  • @Andr_e_y
    @Andr_e_y 2 роки тому

    I haven't tried TF, I use Pytorch

  • @tljstewart
    @tljstewart 2 роки тому

    Perfect!

  • @dustinwilliams448
    @dustinwilliams448 2 роки тому +1

    Thanks for all the great info.. not sure the results are meaningful , if you’re not doing a 1:1 test it’s not very informative

  • @elyasaf755
    @elyasaf755 2 роки тому +3

    Tensorflow is much better and well polished imo

    • @maelstrom254
      @maelstrom254 2 роки тому

      It’s basically dead

    • @elyasaf755
      @elyasaf755 2 роки тому +1

      @@maelstrom254 you're trolling, right? xD

    • @maelstrom254
      @maelstrom254 2 роки тому

      @@elyasaf755 look at usage statistics. Plus I personally don’t know who would prefer Tensorflow (we have several floors of research department)

  • @leo.y.comprendo
    @leo.y.comprendo 2 роки тому +1

    #TeamPytorch

  • @stayhappylittlemermaid
    @stayhappylittlemermaid 2 роки тому +7

    If you are insecure, guess what? The rest of the world is, too. Do not overestimate the competition and underestimate yourself. You are better than you think.

  • @haroonrehman8156
    @haroonrehman8156 Рік тому

    I miss your channel's previous name

  • @sauravmay
    @sauravmay Місяць тому

    The entire content and Speaking are done through AI voice and few screens are incorporated manually.....

  • @tilkesh
    @tilkesh 5 місяців тому

    print('Thanks')

  • @VegetableJuiceFTW
    @VegetableJuiceFTW 2 роки тому

    this video was unfair and inconclusive

  • @davidademola3770
    @davidademola3770 Рік тому

    Jesus Christ 😭🙆

  • @Raaj_ML
    @Raaj_ML 2 місяці тому

    Are you taking a session or just reading out something ? Sorry...teaching is not reading out something fast like this !

  • @omicronsrule6565
    @omicronsrule6565 Рік тому

    So bad