for layer_forbidden in args.layers_NOT_to_prune:
                if layer_forbidden in name:
                    flag = False
            if flag:
                tot_sparsity += 100. * float(torch.sum(
                    module.weight == 0)) / float(module.weight.nelement())
                tot_weight += float(module.weight.nelement()) - float(
                    torch.sum(module.weight == 0))

                if args.logs_layers:
                    print("Sparsity in {}.weight: {:.2f}%".format(
                        str(name),
                        100. * float(torch.sum(module.weight == 0)) /
                        float(module.weight.nelement())))
if flag2:
    nn_model_ref.eval_all(["val"])

df_exp_1 = pd.read_csv(
    "results/table_of_truth_v2/speck/5/ctdata0l^ctdata1l_ctdata0r^ctdata1r^ctdata0l^ctdata1l_ctdata0l^ctdata0r_ctdata1l^ctdata1r/2020_07_21_13_51_48_837739/expression_bool_per_filter.csv"
)
df_exp_2 = pd.read_csv(
    "results/table_of_truth_v2/speck/5/ctdata0l^ctdata1l_ctdata0r^ctdata1r^ctdata0l^ctdata1l_ctdata0l^ctdata0r_ctdata1l^ctdata1r/2020_07_21_13_51_48_837739/expression_bool_per_filter_withpadbegin.csv"
)
df_exp_3 = pd.read_csv(
    "results/table_of_truth_v2/speck/5/ctdata0l^ctdata1l_ctdata0r^ctdata1r^ctdata0l^ctdata1l_ctdata0l^ctdata0r_ctdata1l^ctdata1r/2020_07_21_13_51_48_837739/expression_bool_per_filter_withpadend.csv"
)

unique_feature = df_exp_1.columns[1:]
print("Nbre de features: ", 16 * len(unique_feature))

X_train = np.zeros(
Esempio n. 2
0
        print()
        print("NEW DATA: " + str(args.create_new_data_for_classifier))
        print()

        generator_data = Genrator_data_prob_classifier(
            args, nn_model_ref.net, path_save_model, rng, creator_data_binary,
            device, get_masks_gen.masks, nn_model_ref)
        generator_data.create_data_g(table_of_truth)
        #EVALUATE GOHR NN ON NEW DATASET
        nn_model_ref.X_train_nn_binaire = generator_data.X_bin_train
        nn_model_ref.X_val_nn_binaire = generator_data.X_bin_val
        nn_model_ref.Y_train_nn_binaire = generator_data.Y_create_proba_train
        nn_model_ref.Y_val_nn_binaire = generator_data.Y_create_proba_val

        if args.eval_nn_ref:
            nn_model_ref.eval_all(["train", "val"])
        all_clfs = All_classifier(args, path_save_model, generator_data,
                                  get_masks_gen, nn_model_ref, table_of_truth,
                                  cpt)
        #all_clfs.X_train_proba = np.concatenate((all_clfs.X_train_proba, X_feat_temp), axis = 1)
        #all_clfs.X_eval_proba =  np.concatenate((all_clfs.X_eval_proba, X_feat_temp_val), axis = 1)
        all_clfs.classify_all()

        if args.quality_of_masks:
            qm = Quality_masks(args, path_save_model, generator_data,
                               get_masks_gen, nn_model_ref, table_of_truth,
                               all_clfs)
            qm.start_all()
        else:
            qm = None
Esempio n. 3
0
nn_model_ref.load_nn()
net = nn_model_ref.net
args.nbre_sample_train = nbre_sample_train
del nn_model_ref, creator_data_binary
cpt = 0
for intermedvalue in ["64", "512"]:
    for seed in range(3):
        args.seed = seed
        creator_data_binary = Create_data_binary(args, cipher, rng)
        for repeat in range(5):
            cpt += 1
            nn_model_ref = NN_Model_Ref(args, writer, device, rng, path_save_model, cipher, creator_data_binary, path_save_model_train)
            nn_model_ref.net = net


            nn_model_ref.eval_all(["train", "val"], intermed=intermedvalue)

            X_DDTpd = pd.DataFrame(data=nn_model_ref.all_intermediaire)

            classifiers = [
                #SVC(kernel="linear", C=0.025,random_state=args.seed),
                #SVC(gamma=2, C=1,random_state=args.seed),
                #RandomForestClassifier(max_depth=5, n_estimators=10, max_features=1,random_state=args.seed),
                #MLPClassifier(alpha=1, max_iter=1000,random_state=args.seed),
                "LGBM"]
            for clf in classifiers:
                print("---------------------------"*10)
                print(clf)
                print()
                if clf == "NN":
                    nn_model_ref.train_general(name_input)