[libfann] 207/242: Documentation and default error log

Christian Kastner chrisk-guest at moszumanska.debian.org
Sat Oct 4 21:10:45 UTC 2014


This is an automated email from the git hooks/post-receive script.

chrisk-guest pushed a commit to tag Version2_0_0
in repository libfann.

commit 1eb82cb262987c4fdb86405bc2f8317a4351ee63
Author: Steffen Nissen <lukesky at diku.dk>
Date:   Sun Nov 20 15:36:45 2005 +0000

    Documentation and default error log
---
 ChangeLog                |  2 ++
 src/fann.c               |  2 +-
 src/fann_error.c         | 33 +++++++++++++++++++++------------
 src/include/fann_data.h  |  7 ++++++-
 src/include/fann_error.h | 44 +++++++++++++++++++++++++++++++++++++-------
 src/include/fann_io.h    | 24 +++++++++++++++++++++---
 6 files changed, 88 insertions(+), 24 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index b3718a6..4bcba60 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -10,6 +10,8 @@ libfann (2.0.0) stable; urgency=low
 	* Training can be stopped by counting the number of datasets that fail instead of just MSE
 	* Fixed a memory leak when copying training data
 	* More activation functions
+	* Enums used instead of integers for several parameters.
+	* Possebility to set default logging facility
 
 libfann (1.2.0) stable; urgency=low
 	* Fixes for better compability with different compilers
diff --git a/src/fann.c b/src/fann.c
index 404d7c6..eb1fc18 100644
--- a/src/fann.c
+++ b/src/fann.c
@@ -1101,7 +1101,7 @@ struct fann *fann_allocate_structure(unsigned int num_layers)
 	}
 
 	ann->errno_f = FANN_E_NO_ERROR;
-	ann->error_log = NULL;
+	ann->error_log = fann_default_error_log;
 	ann->errstr = NULL;
 	ann->learning_rate = 0.7;
 	ann->learning_momentum = 0.0;
diff --git a/src/fann_error.c b/src/fann_error.c
index 97ecf6e..17da363 100644
--- a/src/fann_error.c
+++ b/src/fann_error.c
@@ -30,6 +30,8 @@
 #define snprintf _snprintf
 #endif
 
+FILE * fann_default_error_log = (FILE *)-1;
+
 /* resets the last error number
  */
 FANN_EXTERNAL void FANN_API fann_reset_errno(struct fann_error *errdat)
@@ -69,16 +71,19 @@ FANN_EXTERNAL char *FANN_API fann_get_errstr(struct fann_error *errdat)
  */
 FANN_EXTERNAL void FANN_API fann_set_error_log(struct fann_error *errdat, FILE * log_file)
 {
-	errdat->error_log = log_file;
+	if(errdat == NULL)
+		fann_default_error_log = log_file;
+	else
+		errdat->error_log = log_file;
 }
 
-/* prints the last error to the error log (default stderr)
+/* prints the last error to stderr
  */
 FANN_EXTERNAL void FANN_API fann_print_error(struct fann_error *errdat)
 {
-	if((errdat->errno_f != FANN_E_NO_ERROR) && (errdat->error_log != NULL))
+	if(errdat->errno_f != FANN_E_NO_ERROR && errdat->errstr != NULL)
 	{
-		fputs(errdat->errstr, errdat->error_log);
+		fprintf(stderr, "FANN Error %d: %s", errdat->errno_f, errdat->errstr);
 	}
 }
 
@@ -89,6 +94,7 @@ void fann_error(struct fann_error *errdat, const enum fann_errno_enum errno_f, .
 {
 	va_list ap;
 	char *errstr;
+	FILE * error_log = fann_default_error_log;
 
 	if(errdat != NULL)
 		errdat->errno_f = errno_f;
@@ -168,17 +174,20 @@ void fann_error(struct fann_error *errdat, const enum fann_errno_enum errno_f, .
 	}
 	va_end(ap);
 
-	if(errdat == NULL)
+	if(errdat != NULL)
+	{
+		errdat->errstr = errstr;
+		error_log = errdat->error_log;
+		printf("setting errorlog\n");		
+	}
+
+	if(error_log == (FILE *)-1) /* This is the default behavior and will give stderr */
 	{
 		fprintf(stderr, "FANN Error %d: %s", errno_f, errstr);
 	}
-	else
+	else if(error_log != NULL)
 	{
-		errdat->errstr = errstr;
-		if(errdat->error_log != NULL)
-		{
-			fprintf(errdat->error_log, "FANN Error %d: %s", errno_f, errstr);
-		}
+		fprintf(error_log, "FANN Error %d: %s", errno_f, errstr);
 	}
 }
 
@@ -189,5 +198,5 @@ void fann_init_error_data(struct fann_error *errdat)
 {
 	errdat->errstr = NULL;
 	errdat->errno_f = FANN_E_NO_ERROR;
-	errdat->error_log = stderr;
+	errdat->error_log = fann_default_error_log;
 }
diff --git a/src/include/fann_data.h b/src/include/fann_data.h
index 65ec36c..a72ce33 100644
--- a/src/include/fann_data.h
+++ b/src/include/fann_data.h
@@ -26,6 +26,8 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 
 
 /* Type: fann_type
+   fann_type is the type used for the weights, inputs and outputs of the neural network.
+   
 	fann_type is defined as a:
 	float - if you include fann.h or floatfann.h
 	double - if you include doublefann.h
@@ -373,7 +375,10 @@ struct fann_layer
 /* 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 so 
+	<struct fann> and <struct fann_train_data> can be casted to this type.
+	
+	See also:
+		<fann_set_error_log>, <fann_get_errno>
 */
 struct fann_error
 {
diff --git a/src/include/fann_error.h b/src/include/fann_error.h
index 7730a18..086a0cc 100644
--- a/src/include/fann_error.h
+++ b/src/include/fann_error.h
@@ -78,44 +78,74 @@ enum fann_errno_enum
 	
 /* Function: fann_set_error_log
 
-   change where errors are logged to
+   Change where errors are logged to. Both <struct fann> and <struct fann_data> can be 
+   casted to <struct fann_error>, so this function can be used to set either of these.
+   
+   If log_file is NULL, no errors will be printed.
+   
+   If errdata is NULL, the default log will be set. The default log is the log used when creating 
+   <struct fann> and <struct fann_data>. This default log will also be the default for all new structs
+   that are created.
+   
+   The default behavior is to log them to stderr.
+   
+   See also:
+    <struct fann_error>
+   
+   This function appears in FANN >= 1.1.0.   
  */ 
 FANN_EXTERNAL void FANN_API fann_set_error_log(struct fann_error *errdat, FILE * log_file);
 
 
 /* Function: fann_get_errno
 
-   returns the last error number
+   Returns the last error number.
+   
+   See also:
+    <fann_errno_enum>, <fann_reset_errno>
+    
+   This function appears in FANN >= 1.1.0.   
  */ 
 FANN_EXTERNAL enum fann_errno_enum FANN_API fann_get_errno(struct fann_error *errdat);
 
 
 /* Function: fann_reset_errno
 
-   resets the last error number
+   Resets the last error number.
+   
+   This function appears in FANN >= 1.1.0.   
  */ 
 FANN_EXTERNAL void FANN_API fann_reset_errno(struct fann_error *errdat);
 
 
 /* Function: fann_reset_errstr
 
-   resets the last error string
+   Resets the last error string.
+
+   This function appears in FANN >= 1.1.0.   
  */ 
 FANN_EXTERNAL void FANN_API fann_reset_errstr(struct fann_error *errdat);
 
 
 /* Function: fann_get_errstr
 
-   returns the last errstr.
- * This function calls fann_reset_errno and fann_reset_errstr
+   Returns the last errstr.
+  
+   This function calls <fann_reset_errno> and <fann_reset_errstr>
+
+   This function appears in FANN >= 1.1.0.   
  */ 
 FANN_EXTERNAL char *FANN_API fann_get_errstr(struct fann_error *errdat);
 
 
 /* Function: fann_print_error
 
-   prints the last error to stderr
+   Prints the last error to stderr.
+
+   This function appears in FANN >= 1.1.0.   
  */ 
 FANN_EXTERNAL void FANN_API fann_print_error(struct fann_error *errdat);
 
+extern FILE * fann_default_error_log;
+
 #endif
diff --git a/src/include/fann_io.h b/src/include/fann_io.h
index fc8544a..66c95a1 100644
--- a/src/include/fann_io.h
+++ b/src/include/fann_io.h
@@ -23,20 +23,33 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 /* Section: FANN File Input/Output */	
 
 /* Group: File Input and Output */	
-	
+
 /* Function: fann_create_from_file
+   
    Constructs a backpropagation neural network from a configuration file.
- */ 
+   
+   See also:
+   	<fann_save>, <fann_save_to_fixed>
+   	
+   This function appears in FANN >= 1.0.0.
+ */
 FANN_EXTERNAL struct fann *FANN_API fann_create_from_file(const char *configuration_file);
 
 
 /* Function: fann_save
+
    Save the entire network to a configuration file.
- */ 
+   
+   See also:
+    <fann_create_from_file>, <fann_save_to_fixed>
+
+   This function appears in FANN >= 1.0.0.
+ */
 FANN_EXTERNAL void FANN_API fann_save(struct fann *ann, const char *configuration_file);
 
 
 /* Function: fann_save_to_fixed
+
    Saves the entire network to a configuration file.
    But it is saved in fixed point format no matter which
    format it is currently in.
@@ -61,6 +74,11 @@ FANN_EXTERNAL void FANN_API fann_save(struct fann *ann, const char *configuratio
    The fixed point use of this network is only intended for use on machines that
    have no floating point processor, like an iPAQ. On normal computers the floating
    point version is actually faster.
+
+   See also:
+    <fann_create_from_file>, <fann_save>
+
+   This function appears in FANN >= 1.0.0.
 */ 
 FANN_EXTERNAL int FANN_API fann_save_to_fixed(struct fann *ann, const char *configuration_file);
 	

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/debian-science/packages/libfann.git



More information about the debian-science-commits mailing list