tracel-ai / burn

Burn is a new comprehensive dynamic Deep Learning Framework built using Rust with extreme flexibility, compute efficiency and portability as its primary goals.
https://burn.dev
Apache License 2.0
8.34k stars 407 forks source link

MNIST example from the cargo book not working and/or deviating from the official mnist example from the examples #1976

Open exo-cortex opened 1 month ago

exo-cortex commented 1 month ago

Hi, The official mnist-code-along-example from the burn book has numerous problems. If I use the declared version 0.13.2 with the declared features and use only the code form the burn book and copy it there are a few compiler errors:

Also: The official MNIST example is not the same as the one in the burn book. There are a lot of things different. It would be really nice, if the first thing that people arrive at when learning about burn - the tutorial - is really working and also not that confusing. And even if something does not work one could easily check the working code to compare with one's own example. It would be nice, if the all needed includes would also be in the code examples. They could also be hidden like the code blocks here in the nominomicon (nom tutorial) where one can click on the eye-symbol to reveal hidden use-statements.

It's really frustrating especially in this mnist example, because a lot of it only works in the end (when every thing comes together). It's a rather large introduction that takes some time to write down. If in the end it doesn't compile its not really useful as a welcoming tool to the world of burn.

laggui commented 1 month ago

The issue here is that the book is rendered for the last released version (i.e., 0.13.2) while the examples linked are on the main branch.

We could probably link to the release version of the examples: https://github.com/tracel-ai/burn/tree/release/0.13/examples. If you take a look at the example from there, it should match and work.

Also, the hidden code blocks have been added in PR #1742, but since no release has been made the changes were not applied to the book online.

/edit: at the same time, we do have a warning at the beginning of the guide!

image

exo-cortex commented 1 month ago

Thank you for your comment! But even if I check your link (in order to see the examples in version/0.13) the training.rs file has a function run which does not exist in the burn-book example. In the burn-book-example the method is train. So it still deviates in my understanding.

laggui commented 1 month ago

Thank you for your comment! But even if I check your link (in order to see the examples in version/0.13) the training.rs file has a function run which does not exist in the burn-book example. In the burn-book-example the method is train. So it still deviates in my understanding.

Are you perhaps looking at the mnist example and not the guide?

exo-cortex commented 1 month ago

Oh, that could be. But aren't both examples almost identical? I will check out everything! Thank you. (I'd like to mention thought that this is kind of confusing. Why are there 2 examples with mnist?) Could you maybe start the burn-book-example with some text explaining it a bit further, with links to both examples and an explanation to why there are two next to the exact version/commit at which the example is corresponding to the burn-book code-along?

laggui commented 1 month ago

The examples are not identical. The guide only uses the wgpu backend while the mnist example is configurable to demonstrate how to use different backends.

I agree though that they are pretty similar. But we just added a list of examples in PR #1966 which should (hopefully) help clear up the confusion.

nathanielsimard commented 1 month ago

Maybe we should remove the MNIST example and only keep the guide, it's probably less confusing. We may simply convert the current mnist example to a more general image-classification example using cifar instead, or something like that.

antimora commented 1 month ago

Just keep in mind there is web mnist example that uses the output of mnist training. I optimized the model for web.

exo-cortex commented 1 month ago

Maybe a good change would be to rename the mnist-example to something like "multiple_backends_mnist". I feel like it ist mostly designed to showcase the ease of switching between different backends. Mnist is only a means to a goal. "guide" could become "guide_mnist_book" or something.

And maybe just maybe I am simply uniquely stupid and this isn't a problem at all and other people have no problem with this issue ;-)

laggui commented 1 month ago

I think you bring a valid point 🙂 we should probably review the examples name to make them a bit more clear