G&logit anomaly scores, Gaussian&uniform loaders, refactoring #1
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.