Классификация сейсмических сигналов на основе нейросетевых технологий
Рефераты >> Кибернетика >> Классификация сейсмических сигналов на основе нейросетевых технологий

| N | ID | Result |Target|

+-----+------+--------+------+

| 1 | 24 | 0.1279 | 0 |

| 2 | 25 | 0.9929 | 1 |

| 3 | 26 | 0.0960 | 0 |

| 4 | 27 | 0.1463 | 0 |

| 5 | 28 | 0.1238 | 0 |

| 6 | 29 | 0.1320 | 0 |

| 7 | 30 | 0.1478 | 0 |

| 8 | 31 | 0.1235 | 0 |

| 9 | 32 | 0.0740 | 0 |

| 10 | 33 | 0.5140 | 1 |

+-----+------+--------+------+

5. Файл описания функций, типов переменных и используемых библиотек “nvclass.h”.

/*

* --- Neuro classificator---

*

* Common defines

*/

#include <stdio.h>

#include <ctype.h>

#include <stdlib.h>

#include <string.h>

#include <stdarg.h>

#include <time.h>

#include <math.h>

//#include <unistd.h>

//#include <sys/file.h>

#include <fcntl.h>

#define DefName "nvclass.inp"

#define MAXDEF 100

#define MAXLINE 256

#define NMAXPAT 100

#define NMXINP 20

#define NMXUNIT 20

#define CONT 0

#define EXIT_OK 1

#define EXIT_CNT 2

#define RESTART 911

#define MAXEXP 700 /* Max arg exp(arg) without error 'OVERFLOW' */

#define Random 10

#define Gauss 20

#define OK 0

#define Error 1

#define Yes 77

#define No 78

#define Min 0 /* Find_MinMax( .) */

#define Max 1

#define TYPE_ONE 21

#define TYPE_TWO 22

#define TYPE_THREE 23

#define TYPE_FOUR 24

int NDATA = 0;

int NUNIT1 = 0;

int NUNIT2 = 0;

int NUNIT3 = 0;

int NOUT = 1;

int NPATTERN = 0; /* Number of input pattern*/

int NWORK = 0; /* Number of work pattern*/

int NTEST= 0; /* Number of test pattern*/

int result;

int STOP = 0;

int NumOut = 250; /* Number of itteration, after which show result in debugfile. */

int Num_Iter=10;/* The parameters requred in the procecc of */

float Percent=0.25; /* dinamic lerning with change 'eta' */

float LearnTolerance = 0.10;

float TestTolerance = 0.5;

float MAX_ERR=0.00001; /* min error */

float eta = 1.0; /* learning coefficient*/

float MIN_ETA=0.000001;

float **Array_MinMax;

int *Cur_Number;

float W1[NMXINP][NMXUNIT];

float W2[NMXUNIT];

float PromW1[NMXINP][NMXUNIT];

float PromW2[NMXUNIT];

float PromW1_OLD[NMXINP][NMXUNIT];

float PromW2_OLD[NMXUNIT];

float Err1[NMXUNIT];

float Err2;

float OLD_ERROR;

float GL_Error=0.0;

float Out1[NMXUNIT];

float Out2;

char NetStr[20]="Auto"; /* String with pattern of Net Structure*/

int Type = TYPE_THREE; /* Enter the mode of work of programm */

int InitFunc = Random; /* Random [=10] weigth will RandomDistribution Gauss [=20] - . GaussianDistributon */

float Constant = 1; /* RandomDistribution [-Constant,Constant]*/

float Alfa = 0; /* GaussianDistribution [Alfa,Sigma]*/

float Sigma = 1; /* . */

int Widrow = No; /* Nguyen-Widrow initialization start weigth*/

int Loop = 1; /* Number repeat of Learning cycle */

char *PatternFile; /* File with input patterns*/

char *TestVector;

char *ReportFile="report.txt"; /* name of report file */

char *NetworkFile; /* Name of input NetConfig file */

char *ResNetFname; /* Name of output NetConfig file */

int DEBUG = Yes; /* if 'Yes' then debug info in the DebugFile */

char *DebugFile="Logfile.log"; /* Name of the debug file*/

int NumberVector = 0; /* Number of TEST vector */

int Shuffle = Yes; /* Flag - shuffle the input vectors*/

int Scaling = Yes; /* Scaling input vector */

int MaxLearnCycles = 1999; /* Max number of learning iteration */

FILE *Dfp; /* Debug file pointer */

FILE *Rfp; /* Report file pointer*/

typedef struct Pattern {

int ID; /* ID number this vector in all set of pattern */

float *A; /* pattern (vector) A={a[0],a[1], .,a[NDATA]} */

float Target; /* class which this vector is present*/

} PAT;

PAT *Input;

PAT *Work;

PAT *Test;

/* lines in defaults file are in the form "NAME=value" */

typedef struct Default {

char *name; /* name of the default */

char *value; /* value of the default */

} DEF;

/* structure of statistics info about one test vector */

typedef struct Statistic {

int ID; /* Primery number from input file */

float Target;

float TotalRes; /* Total propability */

int Flag; /* Flag = 1, if vector was error and = 0

in over case */

float *result; /* Result of testing vector on current

iteration */

int *TmpFlag; /* analog 'Flag' on current itteration */

int *NumIter; /* Number iteration of learning on which

Learning cycle STOPED */

int **NumLE; /* Error vectors after cycle of learning

was test*/

} STAT;

/* structure of the some result of learning cycle */

typedef struct ResLearning {

int NumIter;

int LearnError[NMAXPAT+1]; /* A[0]-count of error,

A[1]-ID1,

A[2]-ID2, .

A[NMAXRL]-ID?.*/

} RL;

/* function prototypes */

void OnlyTestVector(void);

void TestAfterLearn (void);

void CheckOneVector ( void );

void CrossValidation ( void );

DEF **defbuild(char *filename);

DEF *defread(FILE *fp);

FILE *defopen (char *filename);

char *defvalue(DEF **deflist, const char *name);

int defclose(FILE *fp);

void defdestroy(DEF **, int);

void getvalues(void);

void Debug (char *fmt, .);

void Report (char *fmt, .);

void Widrow_Init(void);

int Init_W( void );

float RavnRaspr(float A, float B);

float NormRaspr(float B,float A);

void ShufflePat(int *INP,int Koll_El);

float F_Act(float x);

float Forward (PAT src);

int LearnFunc (void);

int Reset (float ResErr, int Cnt, int N_Err);

void Update_Last (int n, float Total_Out);

void Update_Prom1 (int n);

void Prom_to_W (void);

void Update_All_W (int num, float err_cur );

void Init_PromW(void);

void Prom_to_OLD(void);

int CheckVector(float Res, PAT src);

int *TestLearn(int *src);

RL FurtherLearning(int NumIteration,

float StartLearnTolerans,

float EndLearnTolerans,

RL src);

STAT *definestat (PAT src);

STAT **DefineAllStat (PAT *src,int Num);

void FillStatForm (STAT *st, int iteration, float res, RL lr);

void FillSimpleStatForm (STAT *st, float res);

void destroystat ( STAT *st, int param);

void DestroyAllStat (STAT **st, int Num);

void PrintStatHeader(void);

void printstat(STAT *st);

void PrintStatLearn(RL src);

void PrintTestStat(STAT **st, int len);

void PrintErrorStat (STAT **st,int Len);

int DefineNetStructure (char *ptr);

void getStructure(char buf[20]);

PAT patcpy (PAT dest, PAT src);

PAT* LocPatMemory(int num);

void ReadPattern (PAT *input, char *name,int Len);

void FreePatMemory(PAT* src, int num);

void ShowPattern (char *fname, PAT *src, int len);

void ShowVector(char *fname,PAT src);


Страница: