mirror of
https://github.com/glouw/tinn
synced 2024-11-21 22:11:21 +03:00
lib names
This commit is contained in:
parent
381929f7be
commit
de6f6f8aca
6
Tinn.c
6
Tinn.c
@ -125,14 +125,14 @@ static void twrand(Tinn t)
|
||||
#endif
|
||||
}
|
||||
|
||||
double ttrain(Tinn t, double* in, double* tg, double rate)
|
||||
double xttrain(Tinn t, double* in, double* tg, double rate)
|
||||
{
|
||||
forewards(t, in);
|
||||
backwards(t, in, tg, rate);
|
||||
return error(t, tg);
|
||||
}
|
||||
|
||||
Tinn tbuild(int nips, int nops, int nhid)
|
||||
Tinn xtbuild(int nips, int nops, int nhid)
|
||||
{
|
||||
Tinn t;
|
||||
t.o = (double*) calloc(nops, sizeof(*t.o));
|
||||
@ -145,7 +145,7 @@ Tinn tbuild(int nips, int nops, int nhid)
|
||||
return t;
|
||||
}
|
||||
|
||||
void tfree(Tinn t)
|
||||
void xtfree(Tinn t)
|
||||
{
|
||||
free(t.w);
|
||||
free(t.h);
|
||||
|
23
Tinn.h
23
Tinn.h
@ -3,24 +3,19 @@
|
||||
|
||||
typedef struct
|
||||
{
|
||||
double* o; /* Output layer */
|
||||
double* h; /* Hidden layer */
|
||||
double* w; /* Training weights */
|
||||
int nops; /* Number of Output Neurons */
|
||||
int nhid; /* Number of Hidden Neurons */
|
||||
int nips; /* Number of Input Neurons */
|
||||
double* o;
|
||||
double* h;
|
||||
double* w;
|
||||
int nops;
|
||||
int nhid;
|
||||
int nips;
|
||||
}
|
||||
Tinn;
|
||||
|
||||
/* Trains a Tinn object given input (in) data, target (tg) data,
|
||||
* and a learning rate (recommended 0.0 - 1.0) */
|
||||
double ttrain(Tinn, double* in, double* tg, double rate);
|
||||
double xttrain(Tinn, double* in, double* tg, double rate);
|
||||
|
||||
/* Returns a Tinn object given number of inputs (nips),
|
||||
* number of outputs (nops), and number of hidden layers (nhid) */
|
||||
Tinn tbuild(int nips, int nops, int nhid);
|
||||
Tinn xtbuild(int nips, int nops, int nhid);
|
||||
|
||||
/* Frees a tinn object from heap memory */
|
||||
void tfree(Tinn);
|
||||
void xtfree(Tinn);
|
||||
|
||||
#endif
|
||||
|
6
test.c
6
test.c
@ -26,11 +26,11 @@ int main()
|
||||
int nops = 1;
|
||||
double* in = inload(nips);
|
||||
double* tg = tgload(nops);
|
||||
Tinn tinn = tbuild(nips, nops, nhid);
|
||||
Tinn tinn = xtbuild(nips, nops, nhid);
|
||||
int i;
|
||||
for(i = 0; i <= 10000; i++)
|
||||
printf("%.18f\n", ttrain(tinn, in, tg, 0.5));
|
||||
tfree(tinn);
|
||||
printf("%.18f\n", xttrain(tinn, in, tg, 0.5));
|
||||
xtfree(tinn);
|
||||
free(in);
|
||||
free(tg);
|
||||
return 0;
|
||||
|
Loading…
Reference in New Issue
Block a user