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

Dropout #73

Merged
merged 5 commits into from
Oct 12, 2019
Merged

Dropout #73

merged 5 commits into from
Oct 12, 2019

Conversation

khornlund
Copy link
Contributor

@khornlund khornlund commented Sep 3, 2019

Hi Luke,

Thanks for sharing this implementation - it's getting a lot of use on Kaggle!

Changes

This PR makes some minor changes to the final layers of the network, in order to allow for a simpler and more flexible implementation of forward():

  1. Pooling and Dropout are stored as attributes on the model with the same name as the Tensorflow implementation, and use nn.Module instead of the functional version. This makes the final layers of the network easier to modify, as users can simply override the values of these attributes.
  2. Reshaping of the data inside forward() has been refactored to use view() instead of multiple calls to squeeze(). This allows users to replace the pooling module without having to conform to dimension requirements.

Notes

Dropout training/eval

The current training check for dropout is no longer necessary:

if self._dropout:
    x = F.dropout(x, p=self._dropout, training=self.training)

When you call net.train() or net.eval(), it recursively sets the training attribute on all child modules. This is then used by the nn.Dropout instance in its call to F.dropout( ... ). Source here.

I've added some tests to make it easy for you to check this.

Modifying the final layers

I've added some tests to show how users can now replace the final layers of the network, without having to subclass EfficientNet and override the forward() method.

Running the tests

pip install pytest
pytest tests/

These tests are provided as a convenience - it's of course up to you whether you want to merge any of them in. Let me know what you think!

Kind Regards,
Karl

@lukemelas lukemelas merged commit d4aed28 into lukemelas:master Oct 12, 2019
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