Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Why do you use your own API #2343

Open
g-i-o-r-g-i-o opened this issue Nov 16, 2022 · 11 comments
Open

Why do you use your own API #2343

g-i-o-r-g-i-o opened this issue Nov 16, 2022 · 11 comments
Labels

Comments

@g-i-o-r-g-i-o
Copy link

g-i-o-r-g-i-o commented Nov 16, 2022

I wonder why are you using an API, instead of regular pytorch code.

It makes everything look unfamiliar and impractical. It's like a new language. Like having to learn everything again.

@astonzhang
Copy link
Member

@AnirudhDagar
Copy link
Member

If you would like to read the regular PyTorch code, you may still access that at https://classic.d2l.ai

@g-i-o-r-g-i-o
Copy link
Author

g-i-o-r-g-i-o commented Nov 17, 2022

Here's why https://d2l.ai/chapter_linear-regression/oo-design.html

It's like dealing with keras. Reading the code of your book is like dealing with a new language. Someone on reddit said that your book wasn't usable because it uses its own api, and I have to agree that it's not accessible anymore, you can't just read it to understand something, first you have to understand what your api does.

Will the classicdhttps://classic.d2l.ai/ still be mantained, or will it die? Even the classic has a wide use of your api.

@g-i-o-r-g-i-o
Copy link
Author

If you would like to read the regular PyTorch code, you may still access that at https://classic.d2l.ai

Thanks but even that isn't classic, it's still full of api calls.
How would I know what this is? Is this equivalent to a dataloader? What is the advantange over importing fashion_minst and then using a DataLoader from torch.utils.data.whatever?
It's like having to learn from zero.

d2l.load_data_fashion_mnist(batch_size=batch_size)

@AnirudhDagar
Copy link
Member

AnirudhDagar commented Nov 17, 2022

@GianniGi I understand your concern and welcome your feedback.

What is the advantange over importing fashion_minst and then using a DataLoader from torch.utils.data.whatever?

If we don't save methods in the d2l lib, that would result in repeated and redundant code. Some code blocks can be utilized again in the latter sections of the book and hence we save them in the d2l lib of the classic version. In a section later, when the same method is used, we can take advantage of the d2l library to call the method without repeating the code.

In this case, https://classic.d2l.ai/chapter_linear-networks/image-classification-dataset.html introduces and explains all the inner workings of load_data_fashion_mnist.

How would I know what this is? Is this equivalent to a dataloader?

If you read the book sequentially, we explain and introduce all the saved methods one by one. In case sequential is not what you are looking for, you can always refer to https://d2l.ai/chapter_appendix-tools-for-deep-learning/d2l.html to find which section defines a particular d2l function.

In the classic version we don't have a wrapper API of any kind, it is just some saved methods which are reused. So essentially the code is still pure PyTorch/TensorFlow/MXNet.

@g-i-o-r-g-i-o
Copy link
Author

g-i-o-r-g-i-o commented Nov 21, 2022

@GianniGi I understand your concern and welcome your feedback.

What is the advantange over importing fashion_minst and then using a DataLoader from torch.utils.data.whatever?

If we don't save methods in the d2l lib, that would result in repeated and redundant code. Some code blocks can be utilized again in the latter sections of the book and hence we save them in the d2l lib of the classic version. In a section later, when the same method is used, we can take advantage of the d2l library to call the method without repeating the code.

Nobody reads a 1000 pages book from the beginning to the end. If you want to save some space, just use some code folding with explicit reference to previous code (i.e. see chapter x for explanation), nothing easier than that. And that's what every author is doing. This is the first time that I see someone using his own api. This book is soon going to be something like lighning or fastai, unusable by definition.

In this case, https://classic.d2l.ai/chapter_linear-networks/image-classification-dataset.html introduces and explains all the inner workings of load_data_fashion_mnist.

How would I know what this is? Is this equivalent to a dataloader?

If you read the book sequentially, we explain and introduce all the saved methods one by one. In case sequential is not what you are looking for, you can always refer to https://classic.d2l.ai/chapter_appendix-tools-for-deep-learning/d2l.html to find which section defines a particular d2l function.

Nobody reads a book sequentially. Books are used also as reference material.

You call your book Dive into Deep Learning, and the ironic part is that you can't dive anywhere, you just have to read your book from the beginning. You should rename it Sequentially and slavishly walk into deep learning.

In the classic version we don't have a wrapper API of any kind, it is just some saved methods which are reused. So essentially the code is still pure PyTorch/TensorFlow/MXNet.

In the classic book you still use your api for many tasks. And surely in the next editions there will be no more classic versions.

@g-i-o-r-g-i-o
Copy link
Author

By the way they stole the title of your book

https://www.amazon.com/Dive-Into-Deep-Learning-Engagement/dp/1544361378

@cx-olquinjica
Copy link
Contributor

I had the same concerns while reading the book, it indeed seems like you have to learn a 'new programming paradigm', but when you think about it, it is actually necessary and understandable why they decided to do it like that (even fast.ai has the same approach), there are some levels of abstraction covered by these API that would confuse people who are just getting started, and the book indeed does a good job presenting the logic behind their implementation on the OOP chapter.

Nevertheless, I saw myself referring back to the implementation of the paradigm more often than necessary, so I wrote this Jupyter Notebook to solidify my understanding of the basic components of the API.

On the other hand, I took it as an opportunity to implement the algorithm on my own in plain PyTorch. So take it as an opportunity for you to implement the algorithm in plain PyTorch or TensorFlow if you like

@g-i-o-r-g-i-o
Copy link
Author

g-i-o-r-g-i-o commented Mar 29, 2023 via email

@cx-olquinjica
Copy link
Contributor

You just got yourself a chance to practice more. The goal of the project is to teach Deep Learning concepts, you can still learn PyTorch by the side, and as I mentioned earlier take it as an opportunity to solidify your understanding of the concepts explained in the book by implementing them in plain PyTorch.
TL:DR Don't think of it as a limitation, it is actually an opportunity. What is torch.nn really?

@g-i-o-r-g-i-o
Copy link
Author

g-i-o-r-g-i-o commented Mar 29, 2023 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants