1 /* 2 * This program is free software; you can redistribute it and/or modify 3 * it under the terms of version 3 or later of the GNU General Public License as 4 * published by the Free Software Foundation. 5 * 6 * This program is distributed in the hope that it will be useful, 7 * but WITHOUT ANY WARRANTY; without even the implied warranty of 8 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 9 * GNU General Public License for more details. 10 * 11 * You should have received a copy of the GNU General Public License 12 * along with this program; if not, write to the Free Software 13 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 14 * 15 * neuralnet.h 16 * 17 * by Gary Wong, 1998 18 * $Id: neuralnet.h,v 1.35 2017/02/18 16:19:44 plm Exp $ 19 */ 20 21 #ifndef NEURALNET_H 22 #define NEURALNET_H 23 24 #include <stdio.h> 25 #include "common.h" 26 27 typedef struct _neuralnet { 28 unsigned int cInput; 29 unsigned int cHidden; 30 unsigned int cOutput; 31 int nTrained; 32 float rBetaHidden; 33 float rBetaOutput; 34 float *arHiddenWeight; 35 float *arOutputWeight; 36 float *arHiddenThreshold; 37 float *arOutputThreshold; 38 } neuralnet; 39 40 typedef enum { 41 NNEVAL_NONE, 42 NNEVAL_SAVE, 43 NNEVAL_FROMBASE 44 } NNEvalType; 45 46 typedef enum { 47 NNSTATE_NONE = -1, 48 NNSTATE_INCREMENTAL, 49 NNSTATE_DONE 50 } NNStateType; 51 52 typedef struct _NNState { 53 NNStateType state; 54 float *savedBase; 55 float *savedIBase; 56 #if !defined(USE_SIMD_INSTRUCTIONS) 57 unsigned int cSavedIBase; 58 #endif 59 } NNState; 60 61 extern void NeuralNetDestroy(neuralnet * pnn); 62 #if !defined(USE_SIMD_INSTRUCTIONS) 63 extern int NeuralNetEvaluate(const neuralnet * pnn, float arInput[], float arOutput[], NNState * pnState); 64 #else 65 extern int NeuralNetEvaluateSSE(const neuralnet * pnn, float arInput[], float arOutput[], NNState * pnState); 66 #endif 67 extern int NeuralNetLoad(neuralnet * pnn, FILE * pf); 68 extern int NeuralNetLoadBinary(neuralnet * pnn, FILE * pf); 69 extern int NeuralNetSaveBinary(const neuralnet * pnn, FILE * pf); 70 extern int SIMD_Supported(void); 71 72 /* Try to determine whether we are 64-bit or 32-bit */ 73 #if defined(_WIN32) || defined(_WIN64) 74 #if defined(_WIN64) 75 #define ENVIRONMENT64 76 #else 77 #define ENVIRONMENT32 78 #endif 79 #endif 80 81 #if defined(__GNUC__) 82 #if defined(__x86_64__) 83 #define ENVIRONMENT64 84 #else 85 #define ENVIRONMENT32 86 #endif 87 #endif 88 89 #endif 90