Ejemplo n.º 1
0
    instances = np.apply_along_axis(utils.add_instances,
                                    category_column=CATEGORY_COLUMN,
                                    instance_column=INSTANCE_COLUMN,
                                    axis=1,
                                    arr=selected_data)
    selected_data[:, CATEGORY_COLUMN] = instances

    # Bring class labels to the range within the number of the classes.
    fitted_class_labels = utils.fit_class_labels(
        selected_data[:, CATEGORY_COLUMN], args.num_classes)
    selected_data[:, CATEGORY_COLUMN] = fitted_class_labels

    train_data = selected_data[np.in1d(selected_data[:, SESSION_COLUMN],
                                       TRAIN_SESSIONS)]
    train_data = utils.reduce_number_of_frames(train_data, FACTOR_FRAMES)
    train_data = utils.select_frames_per_session(
        train_data, NUMBER_FRAMES, FACTOR_FRAMES, CATEGORY_COLUMN,
        SESSION_COLUMN, IMAGE_NAME_COLUMN, TRAIN_SESSIONS)

    test_data = selected_data[np.in1d(selected_data[:, SESSION_COLUMN],
                                      TEST_SESSIONS)]

    # ------------------------------------ Batch learning---------------------------------------------------------------
    if BATCH_LEARNING:
        learning.batch_learning(train_data, test_data, args)

    # ------------------------------------ Iterative learning ----------------------------------------------------------
    if ITERATIVE_LEARNING:
        learning.iterative_learning(train_data, test_data, args,
                                    CATEGORY_COLUMN)
    # frames is 8. In this case it will be reduced to 4 and 2, respectively.

    # ------------------------------------ Initialization --------------------------------------------------------------

    rgwr = GammaGWR()
    utils = Utilities()
    learning = Learning()
    args = utils.parse_arguments()

    # Get data.
    original_data = utils.load_data(args.dataset).values
    original_data_normalized = utils.normalize_data(original_data,
                                                    DATA_DIMENSION)

    train_data = original_data_normalized[np.in1d(
        original_data_normalized[:, SESSION_COLUMN], TRAIN_SESSIONS)]
    train_data = utils.reduce_number_of_frames(train_data, FACTOR_FRAMES)

    test_data = original_data_normalized[np.in1d(
        original_data_normalized[:, SESSION_COLUMN], TEST_SESSIONS)]

    # ------------------------------------ Batch learning---------------------------------------------------------------
    if BATCH_LEARNING:
        learning.batch_learning(train_data, test_data, args)

    # ------------------------------------ Iterative learning ----------------------------------------------------------
    if ITERATIVE_LEARNING:

        learning.iterative_learning(train_data, test_data, args,
                                    INSTANCE_COLUMN)