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

Update examples/MNIST Manifest, including Julia 1.10 #254

Merged
merged 8 commits into from
Jun 10, 2024
Merged

Conversation

ablaom
Copy link
Collaborator

@ablaom ablaom commented May 24, 2024

This PR resolves #234. It updates the example/MNIST to use latest package versions and Julia 1.10

To do:

  • Test notebook locally with GPU switched on (acceleration=CUDALibs()).

cc @EssamWissam

@ablaom ablaom marked this pull request as draft May 24, 2024 04:40
Copy link

codecov bot commented May 26, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 92.11%. Comparing base (b449d80) to head (638a19c).
Report is 48 commits behind head on dev.

Current head 638a19c differs from pull request most recent head 0afbff1

Please upload reports for the commit 0afbff1 to get more accurate results.

Additional details and impacted files
@@            Coverage Diff             @@
##              dev     #254      +/-   ##
==========================================
+ Coverage   92.08%   92.11%   +0.02%     
==========================================
  Files          12       12              
  Lines         316      317       +1     
==========================================
+ Hits          291      292       +1     
  Misses         25       25              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@ablaom ablaom marked this pull request as ready for review May 26, 2024 22:19
@ablaom ablaom requested a review from EssamWisam May 26, 2024 22:21
@@ -77,7 +77,7 @@ function MLJFlux.build(b::MyConvBuilder, rng, n_in, n_out, n_channels)
MaxPool((2, 2)),
Conv((k, k), c2 => c3, pad=(p, p), relu, init=init),
Copy link
Collaborator

Choose a reason for hiding this comment

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

Instead of computing the required padding to perserve image size manually above and passing it here, one can just pass the singleton SamePad()
https://fluxml.ai/Flux.jl/stable/models/layers/#Convolution-Models

Copy link
Collaborator Author

@ablaom ablaom Jun 6, 2024

Choose a reason for hiding this comment

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

Good to know. I will leave it as is, for less "hidden knowledge" for beginners, but will add your alternative in the form of a comment.

batch_size=50,
epochs=10,
rng=123,
)

# You can add Flux options `optimiser=...` and `loss=...` here. At
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
# You can add Flux options `optimiser=...` and `loss=...` here. At
# You can add to the constructor Flux options `optimiser=...` and `loss=...` here. At

because its later mention To run on a GPU, set acceleration=CUDALib() and omit rng. which if followed by a call to machine (so one may think they should add it the machine and not the constructor if that's not explicit.)

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Addressed in a new commit.

@@ -129,7 +130,7 @@ fit!(mach, rows=1:500);
# Computing an out-of-sample estimate of the loss:

predicted_labels = predict(mach, rows=501:1000);
cross_entropy(predicted_labels, labels[501:1000]) |> mean
cross_entropy(predicted_labels, labels[501:1000])
Copy link
Collaborator

Choose a reason for hiding this comment

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

I do personally prefer training and testing data to be separate data structures (or at least to make this more generic by deciding a split size initially that could be changed as needed).

It may confuse some that we are loading the training data of MNIST then using the first 500 examples for actual training and the second 500 for testing/validation.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Addressed.

@@ -63,8 +65,6 @@ struct MyConvBuilder
channels3::Int
end

make2d(x::AbstractArray) = reshape(x, :, size(x)[end])
Copy link
Collaborator

Choose a reason for hiding this comment

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

There is another instance of this below around line 173, should it be also replaced with MLUtils.flatten?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Okay, it looks like make2d is not used, and we can use vec for make1d. So I've done that.


# **Note.** The the higher the number, the deeper the chain parameter.
# **Note.** The higher the number, the deeper the chain parameter.
Copy link
Collaborator

Choose a reason for hiding this comment

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

I don't get in what sense its deeper because perhaps this is using the same number of hidden layers regardless to epochs.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

We are reporting the mean value of weights for different layers. The higher the index, the deeper the layer we are averaging.

Added a comment to clarify, but let me know if this is still not clear or if you believe my assertion is not correct.

Copy link
Collaborator

Choose a reason for hiding this comment

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

OK. I hadn't seen the plot or noticed the div operation when I commented. Now I understand that the higher the index in the means list, the deeper the layer. I think I initially understood "number" to be the epoch number.

Those we can either just assume users will conclude that "number" is the index in the plot or clarify it.

Copy link
Collaborator

Choose a reason for hiding this comment

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

@ablaom this comment.

@ablaom
Copy link
Collaborator Author

ablaom commented Jun 6, 2024

OKay @EssamWisam I'm ready for you to have another look at this.

@EssamWisam
Copy link
Collaborator

OKay @EssamWisam I'm ready for you to have another look at this.

Redefines perfection 👌. I think we are ready to merge this just after we resolve anything, if needed, in my comment above.

@EssamWisam
Copy link
Collaborator

Oh and also after exposing it in the documentation: obvious by moving the tutorial to the docs folder and then putting the path in make.jl (in the commented tutorials section).

@ablaom
Copy link
Collaborator Author

ablaom commented Jun 10, 2024

I think we are ready to merge this just after we resolve anything, if needed, in my comment above.

Sorry, which comment is that?

Oh and also after exposing it in the documentation: obvious by moving the tutorial to the docs folder and then putting the path in make.jl (in the commented tutorials section).

Mmm. I'm going to postpone that step, but thanks for flagging.

@ablaom ablaom merged commit 088e152 into dev Jun 10, 2024
6 checks passed
@ablaom ablaom deleted the mnist-update branch June 10, 2024 23:12
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.

Update examples/MNIST
2 participants