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

Updated Dropout for more input types. #1867

Merged
merged 6 commits into from
Feb 8, 2022
Merged

Updated Dropout for more input types. #1867

merged 6 commits into from
Feb 8, 2022

Conversation

ShoofLLC
Copy link
Contributor

@ShoofLLC ShoofLLC commented Feb 6, 2022

Replacing the call to rand! in the _dropout_mask function to account
for complex (float) data types.

See discussion: #1572

PR Checklist

  • Tests are added
  • Entry in NEWS.md
  • Documentation, if applicable

ShoofLLC and others added 2 commits February 6, 2022 10:00
Replacing the call to rand! in the _dropout_mask function to account
for complex (float) data types.
@codecov-commenter
Copy link

codecov-commenter commented Feb 6, 2022

Codecov Report

Merging #1867 (ccb328c) into master (7b56813) will increase coverage by 0.01%.
The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #1867      +/-   ##
==========================================
+ Coverage   84.50%   84.51%   +0.01%     
==========================================
  Files          21       21              
  Lines        1484     1485       +1     
==========================================
+ Hits         1254     1255       +1     
  Misses        230      230              
Impacted Files Coverage Δ
src/layers/normalise.jl 83.13% <100.00%> (+0.10%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 7b56813...ccb328c. Read the comment docs.

src/layers/normalise.jl Outdated Show resolved Hide resolved
@ShoofLLC
Copy link
Contributor Author

ShoofLLC commented Feb 6, 2022

The return type of dropout if NOT "active" for Int types would be Int.
But when "active" it would be Float.

That doesn't seem like a good thing, so I think that's a no on this one too.

Copy link
Member

@darsnack darsnack left a comment

Choose a reason for hiding this comment

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

Can you add an entry in NEWS.md?

@ShoofLLC
Copy link
Contributor Author

ShoofLLC commented Feb 6, 2022

Can you add an entry in NEWS.md?

This still needs a new review, I've found something while testing with int types.

src/layers/normalise.jl Outdated Show resolved Hide resolved
@ToucheSir
Copy link
Member

The return type of dropout if NOT "active" for Int types would be Int.
But when "active" it would be Float.

This behaviour is already present on master. I don't think it needs to be addressed in this PR. If anything, this PR improves compatibility with int inputs, as before dropout_mask was calling rand!(::AbstractArray{Int}) and silently doing the wrong thing...

@darsnack
Copy link
Member

darsnack commented Feb 6, 2022

The fix should make the inactive path return a chosen float type. It doesn't make sense to return an integer with the scaling.

@ToucheSir
Copy link
Member

The tricky part is that the inactive path doesn't require any scaling. Or put another way, it's semantically equivalent to p=0, which leads to a scaling factor 1/(1-p) === 1. I suppose we could specifically convert or error on integer arrays?

@darsnack
Copy link
Member

darsnack commented Feb 6, 2022

True, but I think the return type should be stable across active/inactive regardless of the actual computation. 1 / (1 - 0) is a float, so I think always converting is reasonable here.

@ShoofLLC
Copy link
Contributor Author

ShoofLLC commented Feb 6, 2022

True, but I think the return type should be stable across active/inactive regardless of the actual computation. 1 / (1 - 0) is a float, so I think always converting is reasonable here.

The tricky part is that the inactive path doesn't require any scaling. Or put another way, it's semantically equivalent to p=0, which leads to a scaling factor 1/(1-p) === 1. I suppose we could specifically convert or error on integer arrays?

Since scaling is not optional, it kinda makes sense to error, it would at least let the user know that something is wrong.

@darsnack
Copy link
Member

darsnack commented Feb 6, 2022

It's not exactly an error, right? Mathematically the correct output exists, but it cannot be an integer except for very limited values of p. Perhaps we can warn though cause converting the type might cause unexpected downstream errors.

Copy link
Member

@darsnack darsnack left a comment

Choose a reason for hiding this comment

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

Either way, I agree with @ToucheSir that we should merge this and then deal with the type stability issue in a separate PR.

@darsnack
Copy link
Member

darsnack commented Feb 8, 2022

Shall we merge this?

@ToucheSir ToucheSir merged commit 1930966 into FluxML:master Feb 8, 2022
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.

4 participants