Module rspamd_fann

This module enables fann interaction in rspamd Please note, that this module works merely if you have ENABLE_FANN=ON option definition when building rspamd

Brief content:

Functions:

rspamd_fann.is_enabled(): function.

rspamd_fann.create(nlayers, [layer1, ... layern]): Creates new neural network with nlayers that contains layer1layern.

rspamd_fann.create_full(params): Creates new neural network with parameters.

rspamd_fann.load(file): function.

rspamd_fann.load_data(data): function.

rspamd_fann:data(): function.

Methods:

rspamd_fann:get_inputs(): method.

rspamd_fann:get_outputs(): method.

rspamd_fann:get_mse(): method.

rspamd_fann:get_layers(): method.

rspamd_fann:save(fname): method.

Functions

The module rspamd_fann defines the following functions.

Function rspamd_fann.is_enabled()

Checks if fann is enabled for this rspamd build

Parameters:

No parameters

Returns:

  • {boolean}: true if fann is enabled

Back to module description.

Function rspamd_fann.create(nlayers, [layer1, ... layern])

Creates new neural network with nlayers that contains layer1layern neurons in each layer

Parameters:

  • nlayers {number}: number of layers
  • layerI {number}: number of neurons in each layer

Returns:

  • {fann}: fann object

Back to module description.

Function rspamd_fann.create_full(params)

Creates new neural network with parameters:

  • layers {table/numbers}: table of layers in form: {N1, N2, N3 … Nn} where N is number of neurons in a layer
  • activation_hidden {string}: activation function type for hidden layers (tanh by default)
  • activation_output {string}: activation function type for output layer (tanh by default)
  • sparsed {float}: create sparsed ANN, where number is a coefficient for sparsing
  • learn {string}: learning algorithm (quickprop, rprop or incremental)
  • randomize {boolean}: randomize weights (true by default)

Parameters:

No parameters

Returns:

  • {fann}: fann object

Back to module description.

Function rspamd_fann.load(file)

Loads neural network from the file

Parameters:

  • file {string}: filename where fann is stored

Returns:

  • {fann}: fann object

Back to module description.

Function rspamd_fann.load_data(data)

Loads neural network from the data

Parameters:

  • file {string}: filename where fann is stored

Returns:

  • {fann}: fann object

Back to module description.

Function rspamd_fann:data()

Returns serialized neural network

Parameters:

No parameters

Returns:

  • {rspamd_text}: fann data

Back to module description.

Methods

The module rspamd_fann defines the following methods.

Method rspamd_fann:get_inputs()

Returns number of inputs for neural network

Parameters:

No parameters

Returns:

  • {number}: number of inputs

Back to module description.

Method rspamd_fann:get_outputs()

Returns number of outputs for neural network

Parameters:

No parameters

Returns:

  • {number}: number of outputs

Back to module description.

Method rspamd_fann:get_mse()

Returns mean square error for ANN

Parameters:

No parameters

Returns:

  • {number}: MSE value

Back to module description.

Method rspamd_fann:get_layers()

Returns array of neurons count for each layer

Parameters:

No parameters

Returns:

  • {table/number}: table with number ofr neurons in each layer

Back to module description.

Method rspamd_fann:save(fname)

Save fann to file named ‘fname’

Parameters:

  • fname {string}: filename to save fann into

Returns:

  • {boolean}: true if ann has been saved

Back to module description.

Back to top.