Dear List !
How do I make a snns pat file ?
I have 8 layer in a raster group and want to use this layers ass
input units.
I believe the way should look simular to this nonsense
1 r.mask (some good training area)
2 r.stat -xxxxxx
3 awk {%%% } printf(/nt #)
4 repet fore the other layers and other train area
No It looks more like this at lesst for an LNKnet pat file
1 r.mask area
2 r.stat -l input=lay1,lay2...... | awk '{printf("class_int %d %d %d %d %d %d %d...more %d\n",$1,$2,$3,$3,$4,$5,$6,$7,$8.....more layer)}'
3 repete for other areas
But the rel problem is how to bulid in the the C soure that LNKnet
produse.
Please GRASS C writes. LNKnet produse C soures classyfy funktion
How make this funktion classyfy Grass raster data ???
AN MLP 2_input,25_hidden,10_output example
/* X2mlp.param */
/* norm: SIMPLE */
/* 2 (all) features */
/* cost_func: SQ_ERR */
/* sigm: SIGM */
/* net: 2,25,10 */
#include <stdio.h>
#include <math.h>
/* function declarations */
extern int classify_X2mlp(/* float *,float * */);
extern int normalize_X2mlp(/* float * */);
#define NRAW_X2mlp 2
#define NINPUTS_X2mlp 2
#define NH1_X2mlp 25
#define NCLASSES_X2mlp 10
int classify_X2mlp (inputs, outputs)
float *inputs,*outputs;
{
int n, best, j, k;
float h1[NH1_X2mlp];
float y[NCLASSES_X2mlp];
static float x_h1[NH1_X2mlp+1][NINPUTS_X2mlp+1] = {
{ 1.048780e+00, -2.359010e+00, -1.970170e+00, },
.......... more floats .................
{ 4.419050e-02, -4.314130e-02, 4.770690e-02, },
};
static float h1_y[NCLASSES_X2mlp+1][NH1_X2mlp+1] = {
{ -1.312270e+00, -3.287920e-01, -1.603640e-01, -3.694100e-01,
...... simular flots are boring and take lots of space .......
6.598780e-02, -2.112230e-02, },
};
float x[NRAW_X2mlp];
int i;
/* load inputs */
for(i = 0; i < NRAW_X2mlp; i++)
x[i] = inputs[i];
/* normalize loaded data */
normalize_X2mlp(x);
/* calculate hidden layer outputs */
for(j = 0; j < NH1_X2mlp; j++){
h1[j] = x_h1[j][NINPUTS_X2mlp];
for(k = 0; k < NINPUTS_X2mlp; k++){
h1[j] += x[k] * x_h1[j][k];
}
}
/* take sigmoids */
for(j = 0; j < NH1_X2mlp; j++){
h1[j] = 1. / (1. + exp(- 1.000000 * h1[j]));
}
/* calculate outputs */
for(j = 0; j < NCLASSES_X2mlp; j++){
y[j] = h1_y[j][NH1_X2mlp];
for(k = 0; k < NH1_X2mlp; k++){
y[j] += h1[k] * h1_y[j][k];
}
}
/* take output sigmoid */
for(j = 0; j < NCLASSES_X2mlp; j++){
y[j] = 1. / (1. + exp(- 1.000000 * y[j]));
}
/* copy outputs */
for(n = 0; n < NCLASSES_X2mlp; n++)
outputs[n] = y[n];
/* find highest output */
for(best = n = 0; n < NCLASSES_X2mlp; n++)
if(outputs[best] < outputs[n]) best = n;
return(best);
}
int normalize_X2mlp(inputs)
float *inputs;
{
int n;
float new_inputs[NRAW_X2mlp];
static float means[NINPUTS_X2mlp] = {
4.055730e-01, 4.734620e-01, };
static float sdevs[NINPUTS_X2mlp] = {
1.496270e-01, 2.022970e-01, };
for(n = 0; n < NINPUTS_X2mlp; n++){
new_inputs[n] = (inputs[n]- means[n]) / sdevs[n];
}
for(n = 0; n < NINPUTS_X2mlp; n++){
inputs[n] = new_inputs[n];
}
return((int) NINPUTS_X2mlp);
}
#undef NRAW_X2mlp
#undef NINPUTS_X2mlp
#undef NH1_X2mlp
#undef NCLASSES_X2mlp
_________________________________________________________________________
Get Your Private, Free E-mail from MSN Hotmail at http://www.hotmail.com.