CNN Flatten Operation Visualized - Tensor Batch Processing for Deep Learning

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

КОМЕНТАРІ • 109

  • @deeplizard
    @deeplizard  6 років тому +8

    Check out the corresponding blog and other resources for this video at: deeplizard.com/learn/video/mFAIBMbACMA

    • @shineshine9599
      @shineshine9599 5 років тому

      U should have 1 million subscriber

    • @MrVampireutd
      @MrVampireutd 5 років тому

      Hello
      I'm facing a problem and I hope you can help me with it
      I'm trying to add values after making the flatten but these values must be based on each image's pixels
      so for each image in the training set im trying to add some values after the flatten to feed it to the fully connected network
      Thanks in advanced

  • @darshanjani7595
    @darshanjani7595 3 роки тому

    Watching the whole ad as well as clicking the ad to support you guys❤️

  • @sourajitsaha4724
    @sourajitsaha4724 5 років тому +12

    t = t.reshape(t.shape[0],-1), works regardless of the number of color channels or even output channels for that matter. It's great fun - watching your videos. They are both stimulating, cognizant and informative - a rare combination to find in tutoring. Cheers mate! Keep up the good work.

    • @deeplizard
      @deeplizard  5 років тому

      Hey Sourajit - Thank you! I really appreciate that, and I'm glad you have enjoyed the playlist!!

  • @crespoo0
    @crespoo0 4 роки тому +3

    One of the best channels!These are videos with high quality content, production animation verbal and visual explanations well put together! Thanks for doing this!

  • @rohitvoleti3409
    @rohitvoleti3409 5 років тому +5

    Really cool animations along with their parallel explanations, nice job

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

    Your amazing work is helping me tremendously, thank you so so much!

  • @min-youngchoi3833
    @min-youngchoi3833 3 роки тому

    I don't expected This was interactive! Awesome!

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

    Why don't you have more subs. This is gold

  • @howardsmith9032
    @howardsmith9032 4 роки тому +1

    Excellent work guys!

  • @vinayaknayak7374
    @vinayaknayak7374 4 роки тому +3

    t.reshape(t.size()[0], t.size()[1] * t.size()[2] * t.size()[3])
    Thanks for this awesome series of tutorials and blogposts. I benefited a lot from this. Keep up the good work :)

  • @vipulmishra554
    @vipulmishra554 5 років тому

    This would probably seem stupid but I'm posting it since it surprisingly worked.
    t.reshape(int(torch.tensor(t.shape)[0]),int(torch.tensor(t.shape)[1])*int(torch.tensor(t.shape)[2])*int(torch.tensor(t.shape)[3]))

  • @sqliu9489
    @sqliu9489 3 роки тому +1

    Thanks for the great videos !

  • @TensorWave
    @TensorWave 5 років тому +1

    Thank you for these Videos. They really help a lot for beginners !

    • @deeplizard
      @deeplizard  5 років тому +1

      Hey Prathmesh - You are welcome!

  • @Livakivi
    @Livakivi 6 років тому +1

    Thank you for another high quality video :)
    Here is one simple solution:
    t.view(t.shape[0], -1)
    get the first (or any) dimension with .shape, and use -1 to flatten the rest

    • @deeplizard
      @deeplizard  6 років тому +1

      Thanks Ulm - You're welcome! Nice solution. I like how this solution generalizes to batches of any size. 🤖

    • @carltondaniel8966
      @carltondaniel8966 5 років тому

      i understood that we combine all the layers from the image matrix to perform flattening operation , but i did not understand why are we doing this , the end result is we pass the values to the soft-max classifier which performs a multi class classification , thanks in advance

  • @tymo3391
    @tymo3391 4 роки тому +1

    very good video!

  • @preritjain3980
    @preritjain3980 5 років тому +36

    t.reshape(t.shape[0],-1)

  • @bidhanmajhi
    @bidhanmajhi 5 років тому +1

    I like the Ted talk in the end

  • @JimmyCheng
    @JimmyCheng 6 років тому +1

    wonderful contents, plz keep up the good work, I just happen to have a project on pytorch this summer, would be immensely helpful!

    • @deeplizard
      @deeplizard  6 років тому

      Thank you Ziqiang! Really appreciate all your comments!

  • @MdHasan-kh4dq
    @MdHasan-kh4dq 5 років тому +1

    It's an awesome series..

    • @deeplizard
      @deeplizard  5 років тому

      Hey Md Hasan - Thank you!

  • @mpalaourg8597
    @mpalaourg8597 4 роки тому +1

    i am a (couple) year late, but ...
    t.reshape(3, -1) does the work for the example of the video
    or
    t.reshape(t.shape[0], -1) does the work for every number of batches

  • @carltondaniel8966
    @carltondaniel8966 5 років тому +1

    wonderful content!!!!

  • @desultorythoughts
    @desultorythoughts 5 років тому +2

    Great Video deserves more views 73 likes and no dislike speaks for itself

  • @ros6143
    @ros6143 3 роки тому +1

    For RGB images with 3 color channels, shouldn't you use 'start_dim=2' instead of 'start_dim-1' so that each color channel of the image is flattened individually? Or do you just flatten all of them at once? Thanks!

  • @Ruhgtfo
    @Ruhgtfo 5 років тому +1

    Mindblow

  • @CoolDude911
    @CoolDude911 5 років тому +1

    There's a frog on a log in a hole at the bottom of the sea. The frog is number width of the image, the log is the height, the hole is the channel and the depth is the index of the image in the data-set. Easy.

    • @deeplizard
      @deeplizard  5 років тому

      I had a lot of fun reading this. 🤣🤣🤣 It's going over my head though, so if it's not completely random, I'd love to hear more.

  • @carltondaniel8966
    @carltondaniel8966 5 років тому +1

    if we have 3 color channels rgb ,when we perform the flatten operation will all the 3 channels combine as one tensor , thanks in advance !!!

    • @deeplizard
      @deeplizard  5 років тому +1

      Yes. Here is some experimental code:
      r = torch.ones(1,2,2)
      g = torch.ones(1,2,2) + 1
      b = torch.ones(1,2,2) + 2
      img = torch.cat(
      (r,g,b)
      ,dim=0
      )
      img.shape
      #output: torch.Size([3, 2, 2])
      img
      #output:
      tensor([[[1., 1.],
      [1., 1.]],
      [[2., 2.],
      [2., 2.]],
      [[3., 3.],
      [3., 3.]]])
      This code gives us an rgb image that has height and width of 2.
      Now, flatten like this:
      img.flatten(start_dim=0)
      #output: tensor([1., 1., 1., 1., 2., 2., 2., 2., 3., 3., 3., 3.])

  • @farhatwissem8497
    @farhatwissem8497 4 місяці тому

    t.reshape(3, -1).squeeze(dim=1)

  • @sumitvaise5452
    @sumitvaise5452 5 років тому

    t.reshape(3,16).squeeze(dim=1)

  • @morten-punnerud_engelstad
    @morten-punnerud_engelstad 6 років тому +1

    t.reshape(-1,16) or
    t.reshape(-1,t.flatten(start_dim=1).shape[1])

    • @deeplizard
      @deeplizard  6 років тому

      Hey Morten - You've got it. They work! Thanks for contributing these! 🚀

  • @syed1297
    @syed1297 4 роки тому

    sound effects are from bisqwit c++ simd videos?

    • @deeplizard
      @deeplizard  4 роки тому

      Many creators use the same sound effects libraries 😄

    • @syed1297
      @syed1297 4 роки тому

      @@deeplizard oh I didn't know that. Great content BTW. Love it, I'm binge-watching.

  • @JimmyCheng
    @JimmyCheng 6 років тому +1

    does modern camera system's eye tracking system use CNN?

    • @deeplizard
      @deeplizard  6 років тому +1

      Hey Ziqiang - Not sure which ones do and which ones don't. We are likely moving in that direction though. Here are a couple of resources that look interesting:
      blogs.nvidia.com/blog/2016/08/30/eye-tracking-deep-learning/
      arxiv.org/abs/1806.10890
      stanford.edu/class/ee267/Spring2018/report_griffin_ramirez.pdf

  • @jacobstech1777
    @jacobstech1777 6 років тому +2

    really good video, why only 467 views?

    • @deeplizard
      @deeplizard  6 років тому +1

      Thanks YUAN! 467 is pretty weak. I know. Hopefully it's only temporary.
      Thank your for your comment. I really appreciate that! :)

    • @jacobstech1777
      @jacobstech1777 6 років тому +1

      deeplizard I am waiting for more pytorch videos🤣

  • @rickam9055
    @rickam9055 5 років тому +1

    You are the god of AI

  • @mohammadsadilkhan1875
    @mohammadsadilkhan1875 5 років тому +1

    img.shape
    #output [a,b,c,d]
    Img=img.reshape(img.shape[0],-1)

  • @pakhomovviktor3149
    @pakhomovviktor3149 6 років тому +2

    "PyTorch’s built-in flatten() method." Hey there, r u sure there is FLATTEN() in Pytorch? Could not find in the official Pytorch documentation.

    • @deeplizard
      @deeplizard  6 років тому +5

      Hey Pakhomov - You are right! The documentation is missing for the flatten function.
      The flatten function is new. It was added in PyTorch 4.0.1.
      This is the commit where the function was added: github.com/pytorch/pytorch/pull/8578
      You can also see it here (search for flatten): github.com/pytorch/pytorch/releases
      There was an issue opened for the documentation issue. Check it out here: github.com/pytorch/pytorch/issues/9876
      The issue was already fixed and merged into the master code branch. You can see it here: pytorch.org/docs/master/
      To get to that link from the official docs page, use the version selector at the top, and choose master.
      Good eye on that one. Great attention to detail! Hope this info helps!

  • @dranaju_oficial
    @dranaju_oficial 6 років тому +28

    t.reshape(3, -1) make the trick

    • @deeplizard
      @deeplizard  6 років тому +1

      Hey Junior - Excellent! I like. 🤖

    • @TerragonDE
      @TerragonDE 6 років тому +3

      @Junior De Jesus nice, now i also understood what exactly the -1 was doing in the last video in the def flatten(t) - function. :D

    • @dranaju_oficial
      @dranaju_oficial 6 років тому +3

      The -1 parameter means that the torch or numpy will figure out the unknown dimension by looking at the 'length of the array and remaining dimensions'

    • @baiyuzhao4281
      @baiyuzhao4281 6 років тому +11

      It's not a good answer, I think it should be t.reshape(t.shape[0], -1).

    • @jonatan01i
      @jonatan01i 4 роки тому +3

      @@baiyuzhao4281 Was it specified that the answer should be general?

  • @ThomasRStevenson
    @ThomasRStevenson 5 років тому

    t = torch.stack((t1,t2,t3)).reshape(3,1,16).squeeze()

  • @pradeepkumar-ew1ze
    @pradeepkumar-ew1ze 3 роки тому

    t.flatten().reshape(3, 16).squeeze() ( sorry for being late to the party :P)

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

    i've been watching these on headphones. untill this video..
    Sudenly earthquake.. evedently my headphones have no base responce :p But my speakers can shake the hosue..

  • @sanjeebsubedi2826
    @sanjeebsubedi2826 3 роки тому

    t2.reshape(t2.shape[0], np.prod(t2.shape[1:]))

  • @akshooter_5010
    @akshooter_5010 4 роки тому +1

    t.reshape(t.flutten(start_dim=1).shap)
    ;)

  • @Normalizing-polyamory
    @Normalizing-polyamory 5 років тому +4

    t.reshape(3,-1)

  • @andresalmodovar3473
    @andresalmodovar3473 3 роки тому +1

    t.reshape(3,16)

  • @DanNovischi
    @DanNovischi 5 років тому

    t = t.reshape(dim, t.shape[0], 1, -1)
    t = t.squeeze()

  • @gabe8168
    @gabe8168 3 роки тому

    print(t.reshape(3, -1))

  • @grizzle8911
    @grizzle8911 4 роки тому

    t.reshape(-1, 16)

  • @djfl58mdlwqlf
    @djfl58mdlwqlf 5 років тому

    what is this "batch"? It's confusing me for a long time

    • @deeplizard
      @deeplizard  5 років тому

      Check out the below video and blog from our Deep Learning Fundamentals course. It is all about batches in deep learning. Let me know if it helps clarify!
      deeplizard.com/learn/video/U4WB9p6ODjM

  • @arastooajorian9069
    @arastooajorian9069 3 роки тому

    b.reshape(3,-1)

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

    t.reshape(t.shape[0],int(t.numel()/t.shape[0])) this will work as well

  • @theflippedbit
    @theflippedbit 4 роки тому

    Damn, every time I see a video of yours it makes me feel bad as in why haven't I subscribed to your Patreon account yet. Such is the quality and effort made in every single frame in every video. Feels like stealing.

  • @kanthikiransirra7535
    @kanthikiransirra7535 4 роки тому

    t.reshape(1,3,16)

  • @ShivamYadav-rx3hy
    @ShivamYadav-rx3hy 5 років тому +1

    T.reshape(1,-1)[1]

  • @leminhhung151
    @leminhhung151 4 роки тому

    t.reshape(3,1,1,-1).squeeze()

  • @りょりょりょ-b6s
    @りょりょりょ-b6s 4 роки тому

    Alghouth it's late, I am gonna post my answer.
    t.reshape( t.shape[0], -1 )

  • @alihatefi5694
    @alihatefi5694 3 роки тому

    t.reshape(3,1,1,-1)

  • @sulemanrasheed1634
    @sulemanrasheed1634 5 років тому +2

    t = t.reshape(len(t), -1)

  • @chidambarjoshi3470
    @chidambarjoshi3470 9 місяців тому

    t.reshape(1,-1)[1]

  • @amaytrivedi
    @amaytrivedi 5 років тому +1

    reshaped_new_tensor = tensor_reshaped.reshape((1,-1))

  • @gmarcial44
    @gmarcial44 5 років тому

    t.reshape(1,-1)[0]

  • @baqerghezi1342
    @baqerghezi1342 4 роки тому

    t.reshape(len(t[0]),-1)

  • @fardinsaboori8770
    @fardinsaboori8770 3 роки тому

    t.reshape(1,-1)[0,:]

  • @rafail_fridman
    @rafail_fridman 5 років тому +3

    Can you please not include that loud bass sound when you type code? It's really hurts my ears when I watch you in my headphones :(

    • @deeplizard
      @deeplizard  5 років тому

      Hey Raphael - Sorry about that. It's pretty much in for this whole series. I'll consider removing it in future videos. Which brand of headphones are you using? In my headphones it sounds very low and soothing.

    • @floyd084
      @floyd084 5 років тому +1

      I've noticed the high bass in both my headphones and in my car. Your headphones may be lowering the bass.

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

    t=t.reshape(t.shape[0],(torch.numel(t)//t.shape[0])).squeeze()

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

    t.reshape(3, -1)

  • @mariaralucaduminica9916
    @mariaralucaduminica9916 4 роки тому

    t.reshape(3,16)

  • @siddharthshrivastava5823
    @siddharthshrivastava5823 5 років тому +1

    t.reshape(t.shape[0],-1)

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

    t.reshape(3,-1)

  • @PixelPulse168
    @PixelPulse168 3 роки тому +1

    t.reshape(3,-1)

  • @jayachandra677
    @jayachandra677 4 роки тому

    t.reshape(3,-1)

  • @EunYeoWoo
    @EunYeoWoo 5 років тому +1

    t.reshape(3,-1)

  • @harshtiwari9588
    @harshtiwari9588 5 років тому +1

    t.reshape(3,-1)

  • @DeltaSleepy
    @DeltaSleepy 5 років тому +1

    t.reshape(3,-1)

  • @sanskarram992
    @sanskarram992 3 роки тому

    t.reshape(3,-1)

  • @workhard7044
    @workhard7044 4 роки тому

    t.reshape(3,-1)

  • @mohammadwahiduzzamankhan4397
    @mohammadwahiduzzamankhan4397 4 роки тому

    t.reshape(3,-1)

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

    t.reshape(2,-1)

  • @abhishekbhardwaj7214
    @abhishekbhardwaj7214 4 роки тому

    t.reshape(t.shape[0], -1)

  • @vikhyatkumeria1229
    @vikhyatkumeria1229 4 роки тому

    t.reshape(t.shape[0],-1)

  • @jonatan01i
    @jonatan01i 4 роки тому

    t.reshape(t.shape[0], -1)

  • @sachit4
    @sachit4 5 років тому

    t.reshape(t.shape[0], -1)