-
Notifications
You must be signed in to change notification settings - Fork 3
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
Executable tutorial #38
Conversation
paraynaud
commented
Jul 6, 2022
- environnement @example
- add required dependencies
docs/src/tutorial.md
Outdated
w :: Param{Matrix{Float32}} # parameters of the layers | ||
b :: Param{Vector{Float32}} # bias of the layer | ||
# w :: Param{CuArray{Float32, 2, CUDA.Mem.DeviceBuffer}} # for GPU | ||
# b :: Param{CuArray{Float32, 1, CUDA.Mem.DeviceBuffer}} # for GPU |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How about parameterizing so that the user can use the struct on both CPU and GPU?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We know that
Dense(i :: Int, o :: Int, f=sigm) = Dense(param(o, i), param0(o), f)
define the suitable Param
structure.
You want to type it like
struct Dense{
T <: Union{Matrix{Float32}, CuArray{Float32, 2, CUDA.Mem.DeviceBuffer}}
Y <: Union{Vector{Float32}, CuArray{Float32, 1, CUDA.Mem.DeviceBuffer}}
}
w :: Param{T}
b :: Param{Y}
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, for example.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does
struct Dense{T, Y}
w :: Param{T}
b :: Param{Y}
work?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It should work.
I typed it as accurate as I can.
I don't know about the performance (of Union), but I think it is more clear as it is than just T
and Y
.
ed41066
to
0a9c485
Compare
I can't test it on GPU right now, all GPUs are used. |
I tested it on Atlas, and it worked. |
README.md
Outdated
set_size_minibatch!(DenseNetNLPModel, p) # p::Int > 1 | ||
``` | ||
## How to use | ||
Check the [tutorial](https://juliasmoothoptimizers.github.io/KnetNLPModels.jl/dev/tutorial/). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Better point to stable.
@@ -1,5 +1,10 @@ | |||
[deps] | |||
CUDA = "052768ef-5323-5732-b1bb-66c8b64840ba" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
VMs don't always have a GPU. Why not run the docs on CPU?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I added it to run the documentation (mainly the tutorial) on Atlas.
It will be remove by the next commit.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(update) If we remove CUDA, we can't type the Dense
structure like this:
struct Dense{
T <: Union{Matrix{Float32}, CuArray{Float32, 2, CUDA.Mem.DeviceBuffer}}
Y <: Union{Vector{Float32}, CuArray{Float32, 1, CUDA.Mem.DeviceBuffer}}
}
w :: Param{T}
b :: Param{Y}
which makes documentation run fail.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use the more general typing I suggested above. I don't think the Union adds anything.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is done, I think we are ready to go.
docs/src/index.md
Outdated
@@ -18,3 +22,6 @@ In addition, it provides tools to: | |||
- switch the minibatch used to evaluate the neural network; | |||
- change the minibatch size; | |||
- measure the neural network's accuracy at the current `w`. | |||
|
|||
## How to use | |||
Check the [tutorial](https://juliasmoothoptimizers.github.io/KnetNLPModels.jl/dev/tutorial/). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why does this point to dev?
docs/src/tutorial.md
Outdated
@@ -1,6 +1,7 @@ | |||
# KnetNLPModels.jl Tutorial | |||
|
|||
## Synopsis | |||
KnetNLPModels is an interface between [Knet.jl](https://github.com/denizyuret/Knet.jl.git)'s classification neural networks and [NLPModels.jl](https://github.com/JuliaSmoothOptimizers/NLPModels.jl.git). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
too much repetition
aa5d311
to
dba6154
Compare
Co-authored-by: Dominique <dominique.orban@gmail.com>
Co-authored-by: Dominique <dominique.orban@gmail.com>
dba6154
to
b2ae378
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great, thank you!