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

Starting the book. #258

Merged
merged 7 commits into from
Aug 1, 2023
Merged

Starting the book. #258

merged 7 commits into from
Aug 1, 2023

Conversation

Narsil
Copy link
Collaborator

@Narsil Narsil commented Jul 27, 2023

@Narsil Narsil mentioned this pull request Jul 27, 2023
@Narsil
Copy link
Collaborator Author

Narsil commented Jul 28, 2023

Friendly ping for review.


We will now create the hello world of the ML world, building a model capable of solving MNIST dataset.

Open `src/main.rs` and fill in with these contents:
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

these contents -> this content?
Also maybe we should have a repo with the actual files so that it's easier for people that just want to copy the files around?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed typo.

I'm hesitant for the final repo, I'm sure we're not going to keep it enough up to date and currently there's very little content.
But maybe later when the doc grows( and we could inner include too).


## Using a `Linear` layer.

Now that we have this, we might want to complexity a little, for instance by adding `bias` and creating
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

to complexity a little -> to complexify things a bit or something like that?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Indeed !

}
```

This will change the loading code into a new function
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure to understand what "loading code" means in this context, maybe more "model code" or "model running code"?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok I was referring to the loading take up more space.

# }
fn main() -> Result<()> {
// Use Device::new_cuda(0)?; to use the GPU.
let device = Device::Cpu;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

cuda_if_available is nice for this :)

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Very nice indeed. I'll leave the other options in comment, seems core if you need to make sure when a model executes.


## Using `candle_nn`.

For instance [Linear](https://github.com/LaurentMazare/candle/blob/main/candle-nn/src/linear.rs) is already there.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Once the crates are published this should probably point at docs.rs instead of the code as it's nicer for users to look at.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fully agree but we said we'd write it first :)

}
```

Feel free to modify this example to use `Conv2d` to create a classical convnet instead.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Which Conv2d? :)

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Exercise left to the user.

```

At this point, candle will be built **without** CUDA support.
To get CUDA support use the feature `cuda`
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the feature cuda -> the cuda feature?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

@Narsil Narsil merged commit 836ba3e into main Aug 1, 2023
10 checks passed
@LaurentMazare LaurentMazare deleted the start_book branch August 15, 2023 20:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants