C Program crashes after compiling without error - Programmers Heaven

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

Welcome to the new platform of Programmer's Heaven! We apologize for the inconvenience caused, if you visited us from a broken link of the previous version. The main reason to move to a new platform is to provide more effective and collaborative experience to you all. Please feel free to experience the new platform and use its exciting features. Contact us for any issue that you need to get clarified. We are more than happy to help you.

C Program crashes after compiling without error

rodolphombcrodolphombc Posts: 2Member
Hello there.

I'm heaving trouble with a C Program that I'm writing to simulate a Multi-Layer Neural Network. It compiles without any issues, but when I run it, it crashes instantanously. I would be very thankful if anyone could give me a hint. The code is below:

/* Multi layer network to classification of data */

#include
#include
#include
#include
#include

#define MAX_SIZE 1000
#define LRATE 1e-5
#define ERR_LIMIT 1e-3
#define MAX_TIME 55

#define INPUTS 2
#define NEURONSLAYER1 4
#define NEURONSLAYER2 3
#define NEURONSLAYER3 1

#define sqr(x) ((x) * (x))

float max1,max2;

void mapping1(float in[][INPUTS+1], int n) {

int i, j;

if(in[0][1]<0) max1 = (in[0][1])*(-1.0);
else max1=in[0][1];

printf("%f
", max1);

for(i=1;i<n-1;i++)
{
if(in[i][1]>max1 && in[i][1] < 0)max1 = in[i][1]*(-1.0);
if(in[i][1]>max1 && in[i][1] >= 0)max1 = in[i][1];
}

printf("%f
", max1);

for(j=0;jmax2 && in[i][2] < 0)max2 = in[i][2]*(-1.0);
if(in[i][2]>max2 && in[i][2] >= 0)max2 = in[i][2];
}

printf("%f
", max2);

for(j=0;j 0) printf("+1
");
if(OLayerOut[m-1] <= 0) printf("-1
");
}

//Training Routine
else
{
//Read Training
read = scanf("%f,%f,%d", &Input[n][1], &Input[n][2], &ExpectedOut[n]);
n++;
//Check condition for initialization of training
if(Input[n-1][1] == 0 && Input[n-1][2] == 0 && ExpectedOut[n-1] == 0)
{

mapping1(Input,n);
c = max1;
mapping2(Input,n);
d = max2;

//Begin Training
do{
//If the program takes too long, break
if((time(NULL) - start) > MAX_TIME)
{
flag = 1;
break;
}

//If the set is over but the training isn't, restart
if(l == (n-1))
{
l=0;
error_sum = 0;
}

//Initiates over the training set
for(l=0;l ERR_LIMIT );
flag = 1;
}
}
}while(read != EOF);

return 0;
}



Comments

Sign In or Register to comment.