fann icon indicating copy to clipboard operation
fann copied to clipboard

modify function signatures to allow passing back errors

Open jjYBdx4IL opened this issue 9 years ago • 5 comments

Fixes https://github.com/libfann/fann/issues/69

jjYBdx4IL avatar Jun 16 '16 21:06 jjYBdx4IL

This is completely superfluous because the struct fann_train_data can be cast to a fann_error:

/* Struct: struct fann_error

    Structure used to store error-related information, both
    <struct fann> and <struct fann_train_data> can be casted to this type.

    See also:
        <fann_set_error_log>, <fann_get_errno>
*/

If you want to get the error do something like this:

struct fann_train_data *data = fann_read_train_from_file(filename);
struct fann_error *err = (struct fann_error *)data;
if(err->errno_f != FANN_E_NO_ERROR) {
    // do something
}

Or use one of the many errno functions in fann_error.c .

joelself avatar Jun 16 '16 23:06 joelself

okay, I now changed the patch to a minimal, non-API-changing modification. It just sets ann->errno_f after failing to load training data. It's not the exact error and there is no error message, but at least we can detect an error now by reading errno_f.

jjYBdx4IL avatar Jun 17 '16 10:06 jjYBdx4IL

I would suggest to use fann_error and possibly create a new error type for that purpose so it's more consistent and also the message is set.

bukka avatar May 19 '18 10:05 bukka

We should probably review PR #80(?) and get it working, as it supports a new way to handle errors.

Edit: Ignore this comment.

andersfylling avatar Jun 02 '18 12:06 andersfylling

@andersfylling, what do you mean by "new way to handle errors"? I went through the PR you mention and could only find a commit mentioning the "error function", i.e. the function that is minimized during training.

I agree that it would be nice if we could make error handling more consistent and programmatic in FANN, without output to stderr. This PR might be a good first step for it. (I haven't reviewed it though, so I might be wrong.)

broken-pen avatar Jun 05 '18 20:06 broken-pen