Exemplo n.º 1
0
def get_ge(net_name, model_parameters, load_parameters):
    args = util.EmptySpace()
    for key, value in load_parameters.items():
        setattr(args, key, value)
    folder = "/media/rico/Data/TU/thesis/runs{}/{}".format(
        args.experiment, util.generate_folder_name(args))

    ge_x, ge_y = [], []
    lta, lva, ltl, lvl = [], [], [], []
    for run in runs:
        filename = '{}/model_r{}_{}'.format(
            folder, run, get_save_name(net_name, model_parameters))
        ge_path = '{}.exp'.format(filename)

        y_r = util.load_csv(ge_path, delimiter=' ', dtype=np.float)
        x_r = range(len(y_r))
        ge_x.append(x_r)
        ge_y.append(y_r)

        if show_losses or show_acc:
            ta, va, tl, vl = util.load_loss_acc(filename)
            lta.append(ta)
            lva.append(va)
            ltl.append(tl)
            lvl.append(vl)

    return ge_x, ge_y, (lta, lva, ltl, lvl)
Exemplo n.º 2
0
def run_load(model, l2_penal, noise_level=-1.0, data_set=util.DataSet.RANDOM_DELAY_NORMALIZED):
    args = util.EmptySpace()
    args.use_hw = False
    args.data_set = data_set
    # args.traces_path = "/tudelft.net/staff-bulk/ewi/insy/CYS/spicek/student-datasets/"
    # args.models_path = "/tudelft.net/staff-bulk/ewi/insy/CYS/spicek/rtubbing/"
    args.traces_path = "/media/rico/Data/TU/thesis/data/"
    args.models_path = "/media/rico/Data/TU/thesis/runs3/"
    args.raw_traces = True
    args.train_size = 40000
    args.validation_size = 1000
    args.attack_size = 9000
    args.use_noise_data = True if noise_level > 0 else False
    args.epochs = 75
    args.batch_size = 100
    args.lr = 0.0001
    args.l2_penalty = float(l2_penal)
    args.init_weights = "kaiming"
    args.noise_level = float(noise_level)
    args.type_network = 'HW' if args.use_hw else 'ID'
    args.device = torch.device("cuda")
    args.network_name = model
    args.subkey_index = 2
    args.unmask = True
    args.desync = 0
    args.spread_factor = 1
    args.runs = 5

    # args.kernels = [20]
    # args.layers = [5]
    args.kernels = [100, 50, 25, 20, 15, 17, 10, 7, 5, 3]
    args.layers = [1, 2, 3, 4, 5, 6, 7, 8, 9]
    args.channels = [32]
    args.max_pool = 4

    get_ranks(args)
Exemplo n.º 3
0
        x_exp, y_exp = test_with_key_guess_p(key_guesses_shuffled,
                                             predictions_shuffled,
                                             attack_size=args.attack_size,
                                             real_key=real_key,
                                             use_hw=args.use_hw)
        y.append(y_exp)

    # Calculate the mean over the experiments
    y = np.mean(y, axis=0)
    save_path = '{}model_r{}_{}_f{}.exp'.format(
        folder, run, get_save_name(network_name, model_params), index_filter)
    print("Save path {}".format(save_path))
    save_np(save_path, y, f="%f")


load_args = util.EmptySpace()
load_args.device = util.device
load_args.models_path = "/media/rico/Data/TU/thesis/runs3"
load_args.use_hw = False
load_args.traces_path = "/media/rico/Data/TU/thesis/data/"
load_args.raw_traces = False
load_args.train_size = 40000
load_args.validation_size = 1000
load_args.attack_size = 5000
load_args.use_noise_data = False
load_args.data_set = util.DataSet.RANDOM_DELAY_NORMALIZED
load_args.subkey_index = 2
load_args.desync = 0
load_args.unmask = True
load_args.spread_factor = 1
load_args.epochs = 75