Skip to content

G&logit anomaly scores, Gaussian&uniform loaders, refactoring #1

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

Merged
merged 3 commits into from
Sep 22, 2020

Conversation

guyera
Copy link
Owner

@guyera guyera commented Sep 22, 2020

Important changes:

You must specify the directory where you want your model to be saved (and / or loaded) using --model-dir. Models are now saved after every epoch during training as {model_dir}/checkpoint.pth. The checkpoint includes all the data necessary to continue training where it left off, or begin inference (fully restore the state of the program). Secondly, inference-only models are saved as {model_dir}/model.pth. However, model.pth files are never loaded; only checkpoint.pth files are. model.pth files are only generated for exporting / sharing with other developers, since they are easy to use as they are a direct serialization of the deconf_net.state_dict(), unlike checkpoint.pth files, which are serializations of a proprietary checkpoint (program state) object.

In order to specify that you'd like a model to be loaded when the program starts, you must specify the boolean flag "--load-model". If you want to train a model from scratch, simply leave this boolean flag out.

Rather than an "--eval-only" flag, there is now a "--no-train" flag and a "--no-test" flag. Specifying either of these will skip the corresponding action (validation is considered part of "testing", and so it will also be skipped when the "--no-test" flag is present).

The root data directory (previously hardcoded as ./data) can now be specified via the command line argument "--data-dir". The default is "./data".

Gaussian and uniform data loaders have been implemented. In order to use them, simply specify the "--out-dataset" as "Gaussian" or "Uniform", respectively (case sensitive).

During validation and testing, all three Generalized ODIN anomaly scores are validated / tested. Previously, only h(x) was used as an anomaly score. This commit includes an implementation of g(x) and logit (quotient) scores.

Lastly, the data augmentations were amended. RandomCrop(32, padding = 4) and RandomHorizontalFlip() were added as transformations to the training data. The former makes the model less sensitive to translation, and the latter less sensitive to common natural image orientations. CenterCrop((32, 32)) was added as a transformation to the validation / test data to make cropped ood datasets more difficult; previously, they were 36x36 images with 2-pixel padding on all sides, a factor which is not present in the in-distribution data, which made them more easily separable from in-distribution data.

@mattolson93 mattolson93 merged commit b56c693 into master Sep 22, 2020
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