This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import h5py as h5py | |
import numpy as np | |
import torch.utils.data | |
from torchvision import datasets, transforms | |
source_path = 'path-to-the-extracted-imagenet-dataset' | |
destination_path = 'destination-hdf5-file' | |
# place here your own transforms | |
transform = transforms.Compose([ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import matplotlib.pyplot as plt | |
from secml.adv.attacks import CFoolboxPGD | |
from secml.array import CArray | |
from secml.core.constants import inf | |
from secml.data.loader import CDataLoaderMNIST | |
from secml.ml import CNormalizerMinMax | |
from secml.ml.peval.metrics import CMetric | |
from secml.model_zoo import load_model | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import torch | |
class PyTorchModelTracker: | |
def __init__(self, model): | |
self._func_counter = None | |
self._tracked_x = None | |
self._model = model | |
self.reset() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import seaborn as sns | |
import matplotlib.pyplot as plt | |
sns.set_style('whitegrid') | |
plt.rc('axes', titlesize=18) | |
plt.rc('axes', labelsize=14) | |
plt.rc('xtick', labelsize=13) | |
plt.rc('ytick', labelsize=13) | |
plt.rc('legend', fontsize=13) | |
plt.rc('font', size=13) | |
plt.rc('text', usetex=True) |