-
-
Notifications
You must be signed in to change notification settings - Fork 611
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 docstrings in upsample.jl
, recurrent.jl
, and normalise.jl
#1995
Conversation
Codecov Report
@@ Coverage Diff @@
## master #1995 +/- ##
=======================================
Coverage 87.10% 87.10%
=======================================
Files 20 20
Lines 1528 1528
=======================================
Hits 1331 1331
Misses 197 197
Continue to review full report at Codecov.
|
I tried a lot of filters, but I can't get the doctests for the Dropout layer to pass. The primary cause for this failure is the presence of For example, a regex pattern available here - https://regex101.com/r/1KtxKj/1 - correctly handles the I have converted the |
Additionally, should the |
Instead of trying to match the output, you can add a check that the number of zeros is equal to the dropout rate +- some margin of error. I just checked the docs for |
Co-authored-by: Brian Chen <ToucheSir@users.noreply.github.com>
Thank you for the review, @ToucheSir!
Should I import Statistics in every doctest or should I import it only in the first doctest and group the other doctests together?
Yes, this would make the doctests much cleaner. However, I could not use the
I did this initially (with random values, I really need to stop using random values), but then the extra vertical space taken changed my mind. I'll revert it back! |
914b12d
to
10a2b52
Compare
Co-authored-by: Brian Chen <ToucheSir@users.noreply.github.com>
src/layers/recurrent.jl
Outdated
|
||
# Examples | ||
```jldoctest; filter = r"[+-]?([0-9]*[.])?[0-9]+" | ||
julia> r = RNN(1 => 1); |
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 would be interesting to set the weight and bias to fixed values (even [1.0f0]
might work, but I'm sure you could come up with something better) and show deterministic outputs much like you have for the accum
example above. Really hammer home the iterative nature of the RNN interface
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 tried initializing an RNN with weights by passing them in through the RNNCell
's constructor, but for some reason I cannot get it to work. Could you please let me know how can I set the weights to a fixed value?
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.
Can you share what you tried? That should 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.
I tried everything again today and it works 😅
julia> r = Flux.RNNCell(σ, zeros(1,1), zeros(1,1), zeros(1,1), zeros(1,1));
RNNCell(1 => 1, σ)
julia> y = Flux.Recur(r, ones(1,1));
julia> y.state
1×1 Matrix{Float64}:
1.0
julia> y(ones(1,1)) # σ(0)
1×1 Matrix{Float64}:
0.5
julia> y.state
1×1 Matrix{Float64}:
0.5
julia> Flux.reset!(y)
1×1 Matrix{Float64}:
0.0
julia> y.state
1×1 Matrix{Float64}:
0.0
I am not sure if users are supposed to access these constructors like this? If they are then I can probably add this example to the doctests.
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.
Maybe just a comment that usually one does not create a RNN this way, but this is showing how data and hidden states are propagated?
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.
Not as clearly as shown by the accum
example. I looked up in the documentation but couldn't figure out how to use RNNCell
s to create an example similar to the one using accum
. But, this example does show that reset!
resets the state to state0
of RNNCell
rather than the initial state
passed to Recur
.
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.
You can choose a slightly easier to interpret activation function for the cell. I think sigmoid is a little hard to visualize, but there may be something better than just identity
.
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.
relu
might look good here. I have updated the example to use the weights instead of just setting them to 0 -
julia> r = Flux.RNNCell(relu, ones(1,1), zeros(1,1), ones(1,1), zeros(1,1));
julia> y = Flux.Recur(r, ones(1,1));
julia> y.state
1×1 Matrix{Float64}:
1.0
julia> y(ones(1,1)) # relu(1*1 + 1)
1×1 Matrix{Float64}:
2.0
julia> y.state
1×1 Matrix{Float64}:
2.0
julia> Flux.reset!(y)
1×1 Matrix{Float64}:
0.0
julia> y.state
1×1 Matrix{Float64}:
0.0
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.
Looks good!
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.
Failure on Nightly is from ComponentArrays and can be safely ignored. Thanks for your patient work on this @Saransh-cpp !
Thank you for all the constructive reviews!🎉🎉 |
Added missing docstrings (in the manual), updated the existing ones, and added doctests in the following files -
normalise.jl
recurrent.jl
upsample.jl
PR Checklist