PyTorch vs. TensorFlow - DataLoader example
Key Takeaways
PyTorch and TensorFlow's custom data loaders are compared, highlighting similarities in syntax and functionality, with PyTorch having a single standard way of loading data and TensorFlow having multiple methods.
Full Transcript
throughout these keras code examples i want to highlight instances where it's clear to me where there isn't as much of a large difference between pi torch and tensorflow i know this is a tough decision for many people for me as well it's been tough having to kind of learn pi torch as well as tensorflow and keras but once you kind of get to learn more you you know that it's really doing the same thing it just has a slightly different syntax so in this first video i want to show how pytorch and tensorflow custom data loaders are actually really similar in syntax probably the big difference to me is that tensorflow has many ways of doing this whereas i think pi torch has more of a single standard way of doing this so this is the functionality of pi torch that originally attracted me to switch from keras to pi torch is i really like how easy it is to load a data set and then add some custom pre-processing so in my personal experiments this is manifested in my testing with supervised contrastive learning this is where we load our data set and then we sample a given positive image and then we want to go find a corresponding another positive pair from that same data set so say we sample a cat from cfar 10 we want to go find another cat from cfr 10. this is how we do the supervised contrastive learning task so i really like this functionality that's available with git item in the pi torch dataset class so the question then is how do you do this in chaos in tensorflow and how different is this syntax really you know making these pi torch and keras such different things to learn but so going through these chaos examples i've seen some cases uh so this is an example of the semantic segmentation example from chaos examples where you have this same exact syntax it's just called a keras that utils does sequence so this is one kind of syntax in keras that basically exactly mimics this dataset loader in pi torch but as i mentioned previously there's kind of like a lot of ways to load data sets in tensorflow and keras and i think this makes it more confusing i think this is how it confuses people and people like the simplicity of pi torch at least for this one example so this is just one small case the data set loader of a difference between pi torch and tensorflow throughout this series i'll be trying to find more of these examples where they're really not so dissimilar again this is keras you see initializer length get item and then and this is pi torch this is really the same exact thing so then again so in tensorflow and keras they seem to have a lot of different ways of doing this this is an example of how you pipeline data from a directory that's stored in a file system and folders and then this is another example where you've uh you've loaded the data set into memory and now you turn it into a data object using from tensor slices and now here's the key difference in this syntax instead of doing the logic in this get item function you apply the custom processing to the data set by chaining on dot map and then giving it some function to do with each input sample and its label so in this case train pre-processing it takes in a volume because we're using three-dimensional ct scan classification but it doesn't matter at all what what exactly the data is it could be a text sequence or it could be just a regular rgb image and it applies some processing and it returns a processed volume label so another thing about a pi torch is once you define your data loader and you instantiate it by having say train loader equals torch.utils.edu.dataloader and then this custom train set that we just overwrit with our i think this is called super classic i'm not exactly sure but we see how we inherit the functionality of this dataset class from pi torch and then we write in our own custom logic define an instance of it and now something that i know a lot of people like about pytorch and it's built right into the right as you start off with pi torch they give you a c far 10 example and they show you how to do this visualization of the data set and i just think these these core examples like the start here examples are huge for how people generally not you know not like the super experts who already know exactly what to do but most people who are who are still torn between pi torch or tensorflow like these little examples that help them see how to do certain things so this is how you iterate and sample a batch from this trader train loader you do data editor equals iterator train loader and then dot next but in keras and tensorflow you have the exact same syntax the only difference is that it's slightly different this is when you have a tf.data object you just do take one same exact idea as pipelining this with dot next thanks for watching this quick overview of how the dataset loaders are similar in pi torch as well as tensorflow and keras i hope that videos like this will help people to not feel like i'm isolating them if you've if you're currently working with pytorch and you feel like these keras code examples are isolating you and your tool set i hope that these examples can show you how there's a lot of similarity between these frameworks and learning pytorch will improve your tensorflow skills it won't like hurt it or negatively cause you to say memorize all these things and then overwrite the syntax you memorize for the other language because you know there's a lot of insane similarities between the two so thanks for watching and please check out the chaos code example series if you haven't already
Original Description
I hope the Keras code series isn't off putting to people working with PyTorch! These videos will be interleaved throughout the Keras Code Examples to showcase similarities between the frameworks and show you how to leverage these Keras examples to improve your PyTorch skills if that's your framework of choice.
Please let me know any other examples where you would like a translation from TensorFlow to PyTorch or vice versa! (Sorry no Jax haha)
Links:
PyTorch custom dataloader: https://pytorch.org/tutorials/beginner/data_loading_tutorial.html
3D image classification: https://keras.io/examples/vision/3D_image_classification/
image classification from scratch: https://keras.io/examples/vision/image_classification_from_scratch/
Image segmentation keras: https://keras.io/examples/vision/oxford_pets_image_segmentation/
Keras Examples: https://keras.io/examples/
Thanks for watching! Please subscribe and check out the rest of the Keras Code Examples playlist!
Watch on YouTube ↗
(saves to browser)
Sign in to unlock AI tutor explanation · ⚡30
Playlist
Uploads from Connor Shorten · Connor Shorten · 0 of 60
← Previous
Next →
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
DenseNets
Connor Shorten
DeepWalk Explained
Connor Shorten
Inception Network Explained
Connor Shorten
StackGAN
Connor Shorten
StyleGAN
Connor Shorten
Progressive Growing of GANs Explained
Connor Shorten
Improved Techniques for Training GANs
Connor Shorten
Word2Vec Explained
Connor Shorten
Must Read Papers on GANs
Connor Shorten
Unsupervised Feature Learning
Connor Shorten
Self-Supervised GANs
Connor Shorten
Embedding Graphs with Deep Learning
Connor Shorten
Transfer Learning in GANs
Connor Shorten
ReLU Activation Function
Connor Shorten
AC-GAN Explained
Connor Shorten
SimGAN Explained
Connor Shorten
DC-GAN Explained!
Connor Shorten
ResNet Explained!
Connor Shorten
Graph Convolutional Networks
Connor Shorten
Neural Architecture Search
Connor Shorten
Henry AI Labs
Connor Shorten
Video Classification with Deep Learning
Connor Shorten
BigGANs in Data Augmentation
Connor Shorten
Introduction to Deep Learning
Connor Shorten
EfficientNet Explained!
Connor Shorten
Self-Attention GAN
Connor Shorten
Curriculum Learning in Deep Neural Networks
Connor Shorten
Deep Learning Podcast #1 | Edward Dixon | Stochastic Weight Averaging
Connor Shorten
Deep Compression
Connor Shorten
Skin Cancer Classification with Deep Learning
Connor Shorten
Deep Learning Podcast #2 | Edward Peake | Deep Learning in Medical Imaging
Connor Shorten
The Lottery Ticket Hypothesis Explained!
Connor Shorten
SqueezeNet
Connor Shorten
GauGAN Explained!
Connor Shorten
AutoML with Hyperband
Connor Shorten
DL Podcast #3 | Yannic Kilcher | Population-Based Search
Connor Shorten
Weakly Supervised Pretraining
Connor Shorten
Image Data Augmentation for Deep Learning
Connor Shorten
Unsupervised Data Augmentation
Connor Shorten
Wide ResNet Explained!
Connor Shorten
RevNet: Backpropagation without Storing Activations
Connor Shorten
GANs with Fewer Labels
Connor Shorten
BigBiGAN Unsupervised Learning!
Connor Shorten
Self-Supervised Learning
Connor Shorten
Multi-Task Self-Supervised Learning
Connor Shorten
Self-Supervised GANs
Connor Shorten
Population Based Training
Connor Shorten
Show, Attend and Tell
Connor Shorten
Siamese Neural Networks
Connor Shorten
WaveGAN Explained!
Connor Shorten
VAE-GAN Explained!
Connor Shorten
Evolution in Neural Architecture Search!
Connor Shorten
AI Research Weekly Update August 18th, 2019
Connor Shorten
Weight Agnostic Neural Networks Explained!
Connor Shorten
AI Research Weekly Update August 25th, 2019
Connor Shorten
Neuroevolution of Augmenting Topologies (NEAT)
Connor Shorten
CoDeepNEAT
Connor Shorten
AI Research Weekly Update September 1st, 2019
Connor Shorten
Randomly Wired Neural Networks
Connor Shorten
Genetic CNN
Connor Shorten
More on: CV Basics
View skill →Related Reads
📰
📰
📰
📰
I Found the Neural Network I Built in Class 9 — Here’s What Happened When I Tried to Run It Again
Medium · Deep Learning
Introduction to Deep Learning and Neural Networks: From Human Brain to Artificial Intelligence
Medium · Deep Learning
Want to get started with deep learning
Reddit r/deeplearning
Building a Deepfake Detector From Scratch — What Nobody Tells You
Medium · Deep Learning
🎓
Tutor Explanation
DeepCamp AI