Computer Vision¶
Bayesian CNNs (BCNNs) are created and then tested upon a range of computer vision tasks:
-
vision.
action_args
(args)[source]¶ Make GPU specific changes based upon the system’s setup and the user’s arguments. :param args: Argparser containing desired arguments. :return: Set of kwargs.
-
vision.
fgsm_test
(model, adversary, args, test_loader)[source]¶ Evaluate a standard neural network’s performance when the images being evaluated have adversarial attacks inflicted upon them.
Parameters: - model (Torch Model) – A trained CNN
- adversary – An adversarial object for which attacks can be crafted
- args – Arguments object
- test_loader – Testing dataset
-
vision.
load_data
(args, kwargs)[source]¶ Load in the MNIST dataset are setup batching.
Parameters: - args – Argparser object
- kwargs – GPU specific kwargs
Returns: Train and Test datasets
-
vision.
mcdropout_test
(model, args, test_loader, stochastic_passes=100)[source]¶ Carry out basic tests on the BCNN.
Parameters: - model (Torch Model) – A trained BCNN
- args – Arguments object
- test_loader – Testing dataset
- stochastic_passes (int) – Number of stochastic passes to maker per image
-
vision.
test
(model, args, test_loader)[source]¶ Test a CNN performance
Parameters: - model (Torch Model) – A trained BCNN
- args – Arguments object
- test_loader – Testing dataset
-
vision.
train
(model, opt, epoch, args, train_loader)[source]¶ Train a model.
Parameters: - model (Torch Model) – The model to be trained
- opt – The optimiser to be used during training
- epoch (int) – Number of epochs to be used in training. Note, there is no early stopping in place.
- args – Argparser containing several user defined arguments.
- train_loader – Training data
Returns: Trained model
-
vision.
uncertainty_test
(model, args, test_loader, stochastic_passes=100)[source]¶ Measure the uncertainty values calculated by the BCNN as the images of the MNIST dataset are rotated through 180 degrees.
Parameters: - model (Torch Model) – A trained BCNN
- args – Arguments object
- test_loader – Testing dataset
- stochastic_passes (int) – Number of stochastic passes to maker per image