TrainData

NAME

AI::FANN::TrainData

SYNOPSIS

# Load a train data set from disk...
    $data = AI::FANN::TrainData.new:
        path => 'path/to/train.data';
# ...or generate it procedurally
    $data = AI::FANN::TrainData.new:
        num-data   => 66_000,
        num-input  => 728,
        num-output => 10,
        callback   => &callback;

DESCRIPTION

METHODS

new

# fann_read_train
    # fann_read_train_from_callback
    multi method new (
        Int :$num-data!,
        Int :$num-input!,
        Int :$num-output!,
            :&callback,
    ) returns AI::FANN::TrainData
# fann_read_train_from_file
    multi method new (
        IO() :$path,
    ) returns AI::FANN::TrainData
multi method new (
        :@pairs,
    ) returns AI::FANN::TrainData
# fann_merge_train_data
    multi method new (
        :@data where { .all ~~ TrainData:D },
    ) returns AI::FANN::TrainData

clone

# fann_duplicate_train_data
    method clone returns AI::FANN::TrainData

Returns an exact copy of the calling AI::FANN::TrainData object.

num-data

method num-data returns Int

Returns the number of training patterns in the dataset.

num-input

method num-input returns Int

Returns the number of inputs in each of the training patterns.

num-output

method num-output returns Int

Returns the number of outputs in each of the training patterns.

input

method input returns CArray[CArray[num32]]

Returns the pointer to the input array of arrays.

output

method output returns CArray[CArray[num32]]

Returns the pointer to the output array of arrays.

subset

# fann_subset_train_data
    method subset (
        Int $pos,
        Int $length,
    ) returns AI::FANN::TrainData

Returns an copy of a subset of the calling AI::FANN::TrainData with $length elements, starting with the element at position $pos.

scale

# fann_scale_train_data
    # fann_scale_input_train_data
    # fann_scale_output_train_data
    method scale (
        Range:D $range,
        Bool() :$input,
        Bool() :$output,
    ) returns self

Takes a Range object and applies it to either the inputs of the dataset, its outputs, or both depending on the state of the :input and :output flags. As a result, the values in the affected sets will be scaled to fall within the endpoints of the specified range.

Setting either of the flags to a value that evaluates to True will apply the scaling to that set of data. Setting none of them applies the scaling to both.

Using an infinite Range object is an error.

This is a simplified scaling method, which is mostly useful in examples where it's known that all the data will be in one range and it should be transformed to another range.

It is not recommended to use this on subsets of data as the complete input range might not be available in that subset.

For more powerful scaling, please consider the scale method for AI::FANN.

shuffle

# fann_shuffle_train_data
    method shuffle returns self

Shuffles training data, randomizing the order. This is recommended for incremental training, while it has no influence during batch training.

save

# fann_save_train
    method save ( IO() $path ) returns Bool

Save the training structure to a file at the specified location. This file is suitable to be used as the :path argument to the constructor.

destroy

# fann_destroy_train
    method destroy returns Nil

Destroy the internal representation of this dataset. It's a good idea to make sure to call this for every object that has been created.

COPYRIGHT AND LICENSE

Copyright 2021 José Joaquín Atria

This library is free software; you can redistribute it and/or modify it under the Artistic License 2.0.

AI::FANN v0.2.0

Raku binding to the Fast Artificial Neural Network library

Authors

  • Jonathan Scott Duff
  • José Joaquín Atria

License

Artistic-2.0

Dependencies

Test Dependencies

Provides

  • AI::FANN
  • AI::FANN::Raw
  • AI::FANN::Raw::Base
  • AI::FANN::Raw::Cascade
  • AI::FANN::Raw::Creation
  • AI::FANN::Raw::Error
  • AI::FANN::Raw::IO
  • AI::FANN::Raw::Training

The Camelia image is copyright 2009 by Larry Wall. "Raku" is trademark of the Yet Another Society. All rights reserved.