556. Now, for the fun part, let's perturb the network during inference, and see what happens! We'll use PyTorchFI to perform an injection on a single neuron.
[3, 224, 224], which is the typical size of an image from the ImageNet dataset. So while it is optional in this tutorial, it is important to ensure the input to your model is specified if it is not ImageNet.
torch.nn.Conv2d. However, you can include any set of layers to perform injections on. Under the hood, PyTorchFI will only append
hooksto the layers specified. If you want to include all layers, you can simple use
"all"in the list of layer types. For example, the following are some various ways to initialize PyTorchFI
layer_types = [torch.nn.Conv2d]
layer_types = [torch.nn.Conv2d, torch.nn.Linear]
layer_types = [torch.nn.Linear]
layer_types = ["all"]
fault_injection(...), PyTorchFI will setup a few internal data structures and profile your network to assist with bounds checking during error injections. To print out what PyTorchFI "sees" after the initialization, you can run
[1, 64, 55, 55], which corresponds to the
[batch, C, H, W]size.
layer_typesprovided. In other words, the Layer # specified by the
print_pytorch_fi_summary()is the number that will be used to ID the layer in PyTorchFI.
declare_weight_fi(...)). We then need to pass in the location of the error, which are specified by the args:
value, if it is independent
function, if it is dependent
10000in batch element
0, in layer
2at the tensor location
[4, 2, 4](corresponding to CHW).