# 1: Randomly change labels to another class ---------------------------------------------------------------

        tf_model.update_train_x_y(X_train, Y_train_flipped)
        # 2: Include parameters in model.train() to be for ALL_CNN_C for now ---------------------------------------
        tf_model.train()
        # 2: Include parameters in model.train() to be for ALL_CNN_C for now  --------------------------------------
        flipped_results[flips_idx, random_seed_idx, 1:] = tf_model.sess.run(
            [tf_model.loss_no_reg, tf_model.accuracy_op],
            feed_dict=tf_model.all_test_feed_dict)
        print('Flipped loss: %.5f. Accuracy: %.3f' %
              (flipped_results[flips_idx, random_seed_idx, 1],
               flipped_results[flips_idx, random_seed_idx, 2]))

        train_losses = tf_model.sess.run(
            tf_model.indiv_loss_no_reg, feed_dict=tf_model.all_train_feed_dict)
        train_loo_influences = tf_model.get_loo_influences()

        # 3 -------------------------------------------------------------------------------------------------------------------#

        # # simple test for parallelization (works)
        # np.random.RandomState(100)
        # arr = np.random.randint(0, 10, size=[200000, 5])
        # data = arr.tolist()
        # data[:5]
        # def howmany_within_range(row, minimum, maximum):
        #     """Returns how many numbers lie within `maximum` and `minimum` in a given `row`"""
        #     count = 0
        #     for n in row:
        #         if minimum <= n <= maximum:
        #             count = count + 1
        #     return count
Beispiel #2
0
        # update model's training set w/mislabeled labels and re-train
        tf_model.update_train_x_y(X_train, Y_train_flipped)
        tf_model.train()
        # (what does this part do?) this works the same as orig_results
        flipped_results[flips_idx, random_seed_idx, 1:] = tf_model.sess.run(
            [tf_model.loss_no_reg, tf_model.accuracy_op],
            feed_dict=tf_model.all_test_feed_dict)
        print('Flipped loss: %.5f. Accuracy: %.3f' %
              (flipped_results[flips_idx, random_seed_idx, 1],
               flipped_results[flips_idx, random_seed_idx, 2]))

        #
        train_losses = tf_model.sess.run(
            tf_model.indiv_loss_no_reg, feed_dict=tf_model.all_train_feed_dict
        )  #tf_model.indiv_loss_no_reg from genericNeuralNet.py. Calculates loss for each train data?
        train_loo_influences = tf_model.get_loo_influences(
        )  # tf_model.get_loo_influences from binaryLogisticRegressioWithLBFGS.py this calculates loo influence for each train data?
        print(train_loo_influences.shape)
        print('\n')
        print('\n')
        print(train_loo_influences)
        print('\n')
        print('\n')
        #
        for checks_idx in range(
                num_check_vals
        ):  #num_check_vals = 6 # ACTUAL x-axis of figure 6
            np.random.seed(random_seed + 1)
            num_checks = int(num_train_examples / 20) * (checks_idx + 1)  #

            print('### Flips: %s, rs: %s, checks: %s' %
                  (num_flips, random_seed_idx, num_checks))