Did you know ... Search Documentation:
Pack plfann -- prolog/plfann.pl
PublicShow source

The enclosed files plfann.h, plfann.c and plfann.pl form the SWI-Prolog bindings to the Fast Artificial Neural Network library. fann is an open source ANN-library and is released under the LGPL.

The version of the library for which these bindings are intended to be used with is version 2.1.0. Functions foreseen to be available in release 2.2.0 are equally included, but have been commented out.

On the fann home page, links are provided to the Source Code, the Reference Manual and additionally, more general, materials related to ANN's.

fann home page: http://leenissen.dk/fann/

All available functions are implemented, with the exception of:

  1. fann_create_train_from_callback
  2. fann_set_callback

In total 150 public predicates are defined.

The predicate names, used in this library, are the same as the ones in the reference manual. C-Function-return-arguments are added as an additional (and last) argument to the predicates concerned. In a small number of functions, having length values, like f.e. the length of an input array, these arguments have been removed, as these can be obtained in the prolog interface at relative- ly low cost.

fann can use floats, doubles or fixed point (not for training) representation internally, uncomment the appropriate variable definition in plfann.h.

Three additional functions/predicates have been added:

  1. fann_type(-Type)
    Unifies Type with 'FANN_FLOAT', 'FANN_DOUBLE' or 'FANN_FIXED', depending
    on the compilation of the library.
  2. fann_error(+ErrorData)
    Is true if an error occurred. ErrorData refers to the ErrorData set by
    fann_set_error_log/2, or if no ErrorData is specifically set, to 'NULL'.
    The latter is equivalent to calling fann_print_error/0.
  3. fann_print_mode(?Mode)
    Sets  the printing  of the  library to  either  standard  output  device
    (Mode = 'FANN_NATIVE') or  the  SWI-Prolog  console (Mode = 'FANN_SWI').
    In the latter case, the SWI_Prolog message system is used to this end.
    
    The loading of the plfann-library  (i.e. on startup of SWI-Prolog) auto-
    matically sets the printing mode to 'FANN_SWI'.
    
    When called with a free  variable, Mode unifies  with the current  print
    mode, either 'FANN_SWI' or 'FANN_NATIVE'.

The idea of the above is to ALSO be able to build just one library (as opposed to fann and plfann) with the SWI-Prolog bindings included and still be able to use the same library both directly from C/C++ and SWI-Prolog.

In order for this to work, the header-file fann_swi.h will need to be included in fann.h, by adding the line '#include "fann_swi.h"' (without the single quotes) after the other #include statements (around line 140).

The macro BUILD_FANN_WITH_SWI will need to be defined, when building the fann library.

The header-file fann_swi.h will need to be copied/moved to the "../src/include/" directory of the source distribution, this is also where "fann.h" is located.

The result is that iff the library is loaded through SWI-Prolog, the printing of all output of the library will be directed to the SWI-Prolog console. If loaded by another application or library, the standard output is used by default. It is possible to override this behaviour, both from c and from prolog, see fann_swi.h for details.

fann can use floats, doubles or fixed point (not for training) representation internally, uncomment the appropriate macro definition in plfann.h.

There are some issues with saving networks to file. See post "Patch to ensure locale independancy", http://leenissen.dk/fann/forum/viewtopic.php?f=2&t=595 . A patch is posted.

dated: 18.12.2009

author
- Degski
- PiotrLi
license
- LGPL
 fann_type(-Type) is det
Unifies Type with 'FANN_FLOAT', 'FANN_DOUBLE' or 'FANN_FIXED', depending on the compilation of the library.
 fann_set_type(+Type) is det
Sets the library depending type of compilation.

You can choose 'FANN_FLOAT', 'FANN_DOUBLE' or 'FANN_FIXED'

See also
- fann_type/1
 fann_swi_mode is det
Sets the printing of the library to the SWI-Prolog console.
 fann_print_mode(?Mode) is det
Sets the printing of the library to either standard output device (Mode = 'FANN_NATIVE') or the SWI-Prolog console (Mode = 'FANN_SWI'). In the latter case, the SWI_Prolog message system is used to this end.

The loading of the plfann-library (i.e. on startup of SWI-Prolog) auto- matically sets the printing mode to 'FANN_SWI'.

When called with a free variable, Mode unifies with the current print mode, either 'FANN_SWI' or 'FANN_NATIVE'.

 fann_create_standard(_, A, B, X)
bug
- First argument is the number of layers, but is ignored
 fann_create_standard_array(X, Y)
 fann_create_standard_array(_, X, Y)
bug
- First argument is the number of layers, but is ignored
 fann_create_sparse(Y, _, A, B, X)
bug
- First argument is the number of layers, but is ignored
 fann_create_sparse_array(X, _, Y, Z)
bug
- First argument is the number of layers, but is ignored
 fann_create_shortcut(_, A, B, X)
bug
- First argument is the number of layers, but is ignored
 fann_create_shortcut_array(+X:list, -Y:var) is det
 fann_create_shortcut_array(_, X, Y)
bug
- First argument is the number of layers, but is ignored
 fann_error(+ErrorData)
Is true if an error occurred. ErrorData refers to the ErrorData set by fann_set_error_log/2, or if no ErrorData is specifically set, to 'NULL'. The latter is equivalent to calling fann_print_error/0.
 fann_print_error(ErrorData)
 fann_print_error

Undocumented predicates

The following predicates are exported, but not or incorrectly documented.

 fann_create_standard(Arg1, Arg2, Arg3, Arg4, Arg5)
 fann_create_standard(Arg1, Arg2, Arg3, Arg4, Arg5, Arg6)
 fann_create_standard(Arg1, Arg2, Arg3, Arg4, Arg5, Arg6, Arg7)
 fann_create_sparse(Arg1, Arg2, Arg3, Arg4, Arg5, Arg6)
 fann_create_sparse(Arg1, Arg2, Arg3, Arg4, Arg5, Arg6, Arg7)
 fann_create_sparse(Arg1, Arg2, Arg3, Arg4, Arg5, Arg6, Arg7, Arg8)
 fann_create_sparse_array(Arg1, Arg2, Arg3)
 fann_create_shortcut(Arg1, Arg2, Arg3, Arg4, Arg5)
 fann_create_shortcut(Arg1, Arg2, Arg3, Arg4, Arg5, Arg6)
 fann_create_shortcut(Arg1, Arg2, Arg3, Arg4, Arg5, Arg6, Arg7)
 fann_destroy(Arg1)
 fann_run(Arg1, Arg2, Arg3)
 fann_run_unsafe(Arg1, Arg2, Arg3)
 fann_randomize_weights(Arg1, Arg2, Arg3)
 fann_init_weights(Arg1, Arg2)
 fann_print_connections(Arg1)
 fann_print_parameters(Arg1)
 fann_get_num_input(Arg1, Arg2)
 fann_get_num_output(Arg1, Arg2)
 fann_get_total_neurons(Arg1, Arg2)
 fann_get_total_connections(Arg1, Arg2)
 fann_get_network_type(Arg1, Arg2)
 fann_get_connection_rate(Arg1, Arg2)
 fann_get_num_layers(Arg1, Arg2)
 fann_get_layer_array(Arg1, Arg2)
 fann_get_bias_array(Arg1, Arg2)
 fann_get_connection_array(Arg1, Arg2)
 fann_set_weight_array(Arg1, Arg2)
 fann_set_weight(Arg1, Arg2, Arg3, Arg4)
 fann_set_user_data(Arg1, Arg2)
 fann_get_user_data(Arg1, Arg2)
 fann_get_decimal_point(Arg1, Arg2)
 fann_get_multiplier(Arg1, Arg2)
 fann_train(Arg1, Arg2, Arg3)
 fann_test(Arg1, Arg2, Arg3)
 fann_get_MSE(Arg1, Arg2)
 fann_get_bit_fail(Arg1, Arg2)
 fann_reset_MSE(Arg1)
 fann_train_on_data(Arg1, Arg2, Arg3, Arg4, Arg5)
 fann_train_on_file(Arg1, Arg2, Arg3, Arg4, Arg5)
 fann_train_epoch(Arg1, Arg2)
 fann_test_data(Arg1, Arg2, Arg3)
 fann_read_train_from_file(Arg1, Arg2)
 fann_destroy_train(Arg1)
 fann_shuffle_train_data(Arg1)
 fann_scale_train(Arg1, Arg2)
 fann_descale_train(Arg1, Arg2)
 fann_set_input_scaling_params(Arg1, Arg2, Arg3, Arg4)
 fann_set_output_scaling_params(Arg1, Arg2, Arg3, Arg4)
 fann_set_scaling_params(Arg1, Arg2, Arg3, Arg4, Arg5, Arg6)
 fann_clear_scaling_params(Arg1)
 fann_scale_input(Arg1, Arg2)
 fann_scale_output(Arg1, Arg2)
 fann_descale_input(Arg1, Arg2)
 fann_descale_output(Arg1, Arg2)
 fann_scale_input_train_data(Arg1, Arg2, Arg3)
 fann_scale_output_train_data(Arg1, Arg2, Arg3)
 fann_scale_train_data(Arg1, Arg2, Arg3)
 fann_merge_train_data(Arg1, Arg2, Arg3)
 fann_duplicate_train_data(Arg1, Arg2)
 fann_subset_train_data(Arg1, Arg2, Arg3, Arg4)
 fann_length_train_data(Arg1, Arg2)
 fann_num_input_train_data(Arg1, Arg2)
 fann_num_output_train_data(Arg1, Arg2)
 fann_save_train(Arg1, Arg2)
 fann_save_train_to_fixed(Arg1, Arg2, Arg3)
 fann_get_training_algorithm(Arg1, Arg2)
 fann_set_training_algorithm(Arg1, Arg2)
 fann_get_learning_rate(Arg1, Arg2)
 fann_set_learning_rate(Arg1, Arg2)
 fann_get_learning_momentum(Arg1, Arg2)
 fann_set_learning_momentum(Arg1, Arg2)
 fann_get_activation_function(Arg1, Arg2, Arg3, Arg4)
 fann_set_activation_function(Arg1, Arg2, Arg3, Arg4)
 fann_set_activation_function_layer(Arg1, Arg2, Arg3)
 fann_set_activation_function_hidden(Arg1, Arg2)
 fann_set_activation_function_output(Arg1, Arg2)
 fann_get_activation_steepness(Arg1, Arg2, Arg3, Arg4)
 fann_set_activation_steepness(Arg1, Arg2, Arg3, Arg4)
 fann_set_activation_steepness_layer(Arg1, Arg2, Arg3)
 fann_set_activation_steepness_hidden(Arg1, Arg2)
 fann_set_activation_steepness_output(Arg1, Arg2)
 fann_get_train_error_function(Arg1, Arg2)
 fann_set_train_error_function(Arg1, Arg2)
 fann_get_train_stop_function(Arg1, Arg2)
 fann_set_train_stop_function(Arg1, Arg2)
 fann_get_bit_fail_limit(Arg1, Arg2)
 fann_set_bit_fail_limit(Arg1, Arg2)
 fann_get_quickprop_decay(Arg1, Arg2)
 fann_set_quickprop_decay(Arg1, Arg2)
 fann_get_quickprop_mu(Arg1, Arg2)
 fann_set_quickprop_mu(Arg1, Arg2)
 fann_get_rprop_increase_factor(Arg1, Arg2)
 fann_set_rprop_increase_factor(Arg1, Arg2)
 fann_get_rprop_decrease_factor(Arg1, Arg2)
 fann_set_rprop_decrease_factor(Arg1, Arg2)
 fann_get_rprop_delta_min(Arg1, Arg2)
 fann_set_rprop_delta_min(Arg1, Arg2)
 fann_get_rprop_delta_max(Arg1, Arg2)
 fann_set_rprop_delta_max(Arg1, Arg2)
 fann_get_rprop_delta_zero(Arg1, Arg2)
 fann_set_rprop_delta_zero(Arg1, Arg2)
 fann_cascadetrain_on_data(Arg1, Arg2, Arg3, Arg4, Arg5)
 fann_cascadetrain_on_file(Arg1, Arg2, Arg3, Arg4, Arg5)
 fann_get_cascade_output_change_fraction(Arg1, Arg2)
 fann_set_cascade_output_change_fraction(Arg1, Arg2)
 fann_get_cascade_output_stagnation_epochs(Arg1, Arg2)
 fann_set_cascade_output_stagnation_epochs(Arg1, Arg2)
 fann_get_cascade_candidate_change_fraction(Arg1, Arg2)
 fann_set_cascade_candidate_change_fraction(Arg1, Arg2)
 fann_get_cascade_candidate_stagnation_epochs(Arg1, Arg2)
 fann_set_cascade_candidate_stagnation_epochs(Arg1, Arg2)
 fann_get_cascade_weight_multiplier(Arg1, Arg2)
 fann_set_cascade_weight_multiplier(Arg1, Arg2)
 fann_get_cascade_candidate_limit(Arg1, Arg2)
 fann_set_cascade_candidate_limit(Arg1, Arg2)
 fann_get_cascade_max_out_epochs(Arg1, Arg2)
 fann_set_cascade_max_out_epochs(Arg1, Arg2)
 fann_get_cascade_max_cand_epochs(Arg1, Arg2)
 fann_set_cascade_max_cand_epochs(Arg1, Arg2)
 fann_get_cascade_num_candidates(Arg1, Arg2)
 fann_get_cascade_activation_functions_count(Arg1, Arg2)
 fann_get_cascade_activation_functions(Arg1, Arg2)
 fann_set_cascade_activation_functions(Arg1, Arg2)
 fann_get_cascade_activation_steepnesses_count(Arg1, Arg2)
 fann_get_cascade_activation_steepnesses(Arg1, Arg2)
 fann_set_cascade_activation_steepnesses(Arg1, Arg2)
 fann_get_cascade_num_candidate_groups(Arg1, Arg2)
 fann_set_cascade_num_candidate_groups(Arg1, Arg2)
 fann_create_from_file(Arg1, Arg2)
 fann_save(Arg1, Arg2)
 fann_save_to_fixed(Arg1, Arg2)
 fann_set_error_log(Arg1, Arg2)
 fann_get_errno(Arg1, Arg2)
 fann_reset_errno(Arg1)
 fann_reset_errstr(Arg1)
 fann_get_errstr(Arg1, Arg2)
 fann_print_error_core(Arg1)