# fann_set_callback

(PECL fann >= 1.0.0)

fann_set_callback — Sets the callback function for use during training

### Description

fann_set_callback ( resource `$ann` , callable `$callback` ) : bool

Sets the callback function for use during training. It means that it is called from fann_train_on_data() or fann_train_on_file().

### Parameters

`ann`

  Neural network resource.

`callback`

  The supplied callback function takes following parameters:

  - `ann` - The neural network resource
  - `train` - The train data resource or `NULL` if called from fann_train_on_file()
  - `max_epochs` - The maximum number of epochs the training should continue
  - `epochs_between_reports` - The number of epochs between calling this function
  - `desired_error` - The desired fann_get_MSE() or fann_get_bit_fail(), depending on the stop function chosen by fann_set_train_stop_function()
  - `epochs` - The current epoch

  The callback should return `TRUE`. If it returns `FALSE`, the training will terminate.

### Return Values

Returns `TRUE` on success, or `FALSE` otherwise.

### See Also

- fann_train_on_data() - Trains on an entire dataset for a period of time
- fann_train_on_file() - Trains on an entire dataset, which is read from file, for a period of time