473,564 Members | 2,798 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

-1.#IND00 problem

Hello people,

I am rather puzzled by this problem I am having with doubles here. The
code seems to execute correctly for awhile and then all a sudden
printfing out my doubles, I get -1.#IND00 which seems to be an
indeterminate or -infinity or something of the such.

I am coding an IAC network and the problem occurs only in learning mode
when the values approach 1.00 (the values SHOULD stay between between
-0.2 and 1.0, but they occasionally go beyond 1.0 which doesn't make
sense to me either but I'm thinking this is all part of the same
problem.

I do NOT have any sort of division in my program so it can not be a
problem of dividing 0/0 like i've seen mentioned on some posts
reporting the -1.#IND00 problem. I tried the _fpreset function to see
if it was a fpu stack poping problem but it doesn't seem to help
either. I also tried global optimizations (/Og) without success.

I am at a loss to understand why this bombs. The activation of nodes is
the first thing that goes kaput. The weights with which we calculate
the activation of nodes stay in the range -0.5 and 2.0. The magnitude
seems reasonable.

Any help would be greatly appreciated. I can post the rest of the code
if you guys need it. This is the core of the calculation. The rest of
the code only really calls these guys.

#include "iac.h"
#include <stdlib.h>
#include <string.h>
#include <stdio.h>
/* Create a iac network and allocates memory for it */
iac IacCreate(int nodeqty, int connectionqty, double learningrate)
{
iac network;
int x = 0;

network.learnin grate = learningrate;

network.nodeqty = nodeqty;
network.nodes = (node*) malloc(sizeof(n ode)*nodeqty);

network.connect ionqty = connectionqty;
network.connect ions = (connection*)
malloc(sizeof(c onnection)*conn ectionqty);

return network;
}

/* Destroys a iac network by freeing all memory allocated for it */
void IacDestroy(iac network)
{
if(network.conn ections != NULL){free(netw ork.connections );}
if(network.node s != NULL){free(netw ork.nodes);}

return;
}

/* We cycle activation through the network */
iac IacCycle(iac network)
{
int x = 0;
double max = 0;
double min = 0;
double activation = 0;
double decay = 0;
double rest = 0;
double netinput = 0;

for(x = 0; x < network.nodeqty ; x++)
{
max = network.nodes[x].max;
min = network.nodes[x].min;
decay = network.nodes[x].decay;
rest = network.nodes[x].rest;
activation = network.nodes[x].activation;

netinput = IacNodeNetInput (network, x);
if(netinput > 0)
{
network.nodes[x].activation += (max - activation)*net input -
decay*(activati on - rest);
}
else
{
network.nodes[x].activation += (activation - min)*netinput -
decay*(activati on - rest);
}
}

return network;
}

/* We cycle activation through the network many times */
iac IacCycles(iac network, int iteration)
{
int x = 0;

for(x = 0; x < iteration; x++)
{
network = IacCycle(networ k);
}

return network;
}

/* We cycle activation a single time through the network */
iac IacLearningCycl e(iac network)
{
// network = IacCycle(networ k);
network = IacWeightsAdjus t(network);

return network;
}

iac IacLearningCycl es(iac network, int iteration)
{
int x = 0;

for(x = 0; x < iteration; x++)
{
network = IacLearningCycl e(network);
}

return network;
}

/* We cycle activation through the network */
iac IacWeightsAdjus t(iac network)
{
int x = 0;
double activation1 = 0.0;
double activation2 = 0.0;
double learningrate = network.learnin grate;
// double average;

for(x = 0; x < network.connect ionqty; x++)
{
activation1 =
network.nodes[network.connect ions[x].connectedto1].activation;
activation2 =
network.nodes[network.connect ions[x].connectedto2].activation;
// average = (activation1 + activation2)/2;

network.connect ions[x].weight +=
learningrate*(( activation1)*(a ctivation2));
}

return network;
}

/* We calculate the net input for the node to process */
double IacNodeNetInput (iac network, int nodetoprocess)
{
int x = 0;
int connectedto1 = 0;
int connectedto2 = 0;
double netinput = 0.0;

for(x = 0; x < network.connect ionqty; x++)
{
connectedto1 = network.connect ions[x].connectedto1;
connectedto2 = network.connect ions[x].connectedto2;

if(connectedto1 == nodetoprocess)
{
netinput += network.connect ions[x].weight *
network.nodes[connectedto2].activation;
}
else if(connectedto2 == nodetoprocess)
{
netinput += network.connect ions[x].weight *
network.nodes[connectedto1].activation;
}
}

return netinput;
}

/* We activate a certain node */
iac IacNodeActivate (iac network, char* concept)
{
int x = 0;

for(x = 0; x < network.nodeqty ; x++)
{
if(!strcmp(netw ork.nodes[x].concept, concept))
{
network.nodes[x].activation = 1.0;
return network;
}
}

return network;
}

/* We inhibit a certain node */
iac IacNodeInhibit( iac network, char* concept)
{
int x = 0;

for(x = 0; x < network.nodeqty ; x++)
{
if(!strcmp(netw ork.nodes[x].concept, concept))
{
network.nodes[x].activation = -1.0;
return network;
}
}

return network;
}

/* We reinforce the pattern */
iac IacPatternActiv ate(iac network, char** concepts, int conceptqty)
{
int x = 0;

for(x = 0; x < conceptqty; x++)
{
network = IacNodeActivate (network, concepts[x]);
}

return network;
}

/* We weaken the pattern */
iac IacPatternInhib it(iac network, char** concepts, int conceptqty)
{
int x = 0;

for(x = 0; x < conceptqty; x++)
{
network = IacNodeInhibit( network, concepts[x]);
}

return network;
}

/* We zero all the node activations */
iac IacNetworkZero( iac network)
{
int x = 0;

for(x = 0; x < network.nodeqty ; x++)
{
network.nodes[x].activation = 0.0;
}

return network;
}

/* Correlate concepts together and leaves no residual trace running
around
the network. We do not want our pattern to be associated with any
other
pattern */
iac IacCorrelateZer o(iac network, char** concepts, int conceptqty)
{
network = IacPatternActiv ate(network, concepts, conceptqty);
network = IacLearningCycl e(network);
network = IacNetworkZero( network);

return network;
}

/* Correlate concepts together but leaves a residual activation running
around the network. This allows for patterns to be associated
together
in what resembles a type of context association. */
iac IacCorrelateRes idual(iac network, char** concepts, int conceptqty)
{
network = IacPatternActiv ate(network, concepts, conceptqty);
network = IacLearningCycl e(network);

return network;
}

/* Decorrelate concepts and leaves no residual trace running around
the network. We do not want our pattern to be associated with any
other
pattern */
iac IacDecorrelateZ ero(iac network, char** concepts, int conceptqty)
{
network = IacPatternInhib it(network, concepts, conceptqty);
network = IacLearningCycl e(network);
network = IacNetworkZero( network);

return network;
}

/* Correlate concepts together but leaves a residual activation running
around the network. This allows for patterns to be associated
together
in what resembles a type of context association. */
iac IacDecorrelateR esidual(iac network, char** concepts, int
conceptqty)
{
network = IacPatternInhib it(network, concepts, conceptqty);
network = IacLearningCycl e(network);

return network;
}

/* Consult the network */
iac IacConsult(iac network, char** concepts, int conceptqty)
{
network = IacPatternActiv ate(network, concepts, conceptqty);
network = IacCycles(netwo rk, 2000);

return network;
}

iac IacNodeAdd(iac network, char* concept)
{
int x = 0;
int temp = 0;
int nodenumber = 0;

/* We create a new node and initialize its attributes */
network.nodes = (node*) realloc(network .nodes,
sizeof(node)*(n etwork.nodeqty+ 1));
strcpy(network. nodes[network.nodeqty].concept, concept);
network.nodes[network.nodeqty].activation = 0.0;
network.nodes[network.nodeqty].decay = 0.1;
network.nodes[network.nodeqty].rest = -0.1;
network.nodes[network.nodeqty].max = 1.0;
network.nodes[network.nodeqty].min = -0.2;

/* We link the newly created node to all the other nodes (except
itself) */
network.connect ions = (connection*) realloc(network .connections,
sizeof(connecti on)*(network.co nnectionqty+net work.nodeqty));
temp = network.connect ionqty + network.nodeqty ;
for(x = network.connect ionqty; x < temp; x++)
{
network.connect ions[x].connectedto1 = network.nodeqty ;
network.connect ions[x].connectedto2 = nodenumber;
network.connect ions[x].weight = -0.1;
nodenumber++;
}
network.connect ionqty = temp;
network.nodeqty += 1;

return network;
}

bool IacConceptExist s(iac network, char* concept)
{
int x = 0;

for(x = 0; x < network.nodeqty ; x++)
{
if(!strcmp(netw ork.nodes[x].concept, concept)){retur n true;}
}

return false;
}

/* Prints out all nodes content to terminal */
void NodesPrint(iac network)
{
int x = 0;

printf("******* *************** *************** *******Nodes\n" );
for(x = 0; x < network.nodeqty ; x++)
{
printf("Concept : %s\t\t activation: %f\n",
network.nodes[x].concept, network.nodes[x].activation);
}
printf("******* *************** *************** ************\n\ n");
}

/* Prints out all weights content to terminal */
void WeightsPrint(ia c network)
{
int x = 0;

printf("******* *************** *************** *****Weights\n" );
for(x = 0; x < network.connect ionqty; x++)
{
printf("Connect ion weight between %i-%i: %f\n",
network.connect ions[x].connectedto1,
network.connect ions[x].connectedto2, network.connect ions[x].weight);
}
printf("******* *************** *************** ************\n\ n");
}

Regards
Jean-François Michaud

Mar 15 '06 #1
5 13604
Jean-François Michaud wrote:
Hello people,

I am rather puzzled by this problem I am having with doubles here. The
code seems to execute correctly for awhile and then all a sudden
printfing out my doubles, I get -1.#IND00 which seems to be an
indeterminate or -infinity or something of the such.

I am coding an IAC network and the problem occurs only in learning mode
when the values approach 1.00 (the values SHOULD stay between between
-0.2 and 1.0, but they occasionally go beyond 1.0 which doesn't make
sense to me either but I'm thinking this is all part of the same
problem.

I do NOT have any sort of division in my program so it can not be a
problem of dividing 0/0 like i've seen mentioned on some posts
reporting the -1.#IND00 problem. I tried the _fpreset function to see
if it was a fpu stack poping problem but it doesn't seem to help
either. I also tried global optimizations (/Og) without success.

I am at a loss to understand why this bombs. The activation of nodes is
the first thing that goes kaput. The weights with which we calculate
the activation of nodes stay in the range -0.5 and 2.0. The magnitude
seems reasonable.

Any help would be greatly appreciated. I can post the rest of the code
if you guys need it. This is the core of the calculation. The rest of
the code only really calls these guys.

#include "iac.h"
#include <stdlib.h>
#include <string.h>
#include <stdio.h>
/* Create a iac network and allocates memory for it */
iac IacCreate(int nodeqty, int connectionqty, double learningrate)
{
iac network;

[snip]

Let's at least see the definition for your iac struct. Better still
would be if you could reduce the code to a minimal but complete sample
that we could compile, run, and test.

Cheers! -M

Mar 15 '06 #2
Jean-Fran?ois Michaud <co*****@comcas t.net> wrote:
Hello people,

I am rather puzzled by this problem I am having with doubles here. The
code seems to execute correctly for awhile and then all a sudden
printfing out my doubles, I get -1.#IND00 which seems to be an
indeterminate or -infinity or something of the such.

I am coding an IAC network and the problem occurs only in learning mode
when the values approach 1.00 (the values SHOULD stay between between
-0.2 and 1.0, but they occasionally go beyond 1.0 which doesn't make
sense to me either but I'm thinking this is all part of the same
problem.

I do NOT have any sort of division in my program so it can not be a
problem of dividing 0/0 like i've seen mentioned on some posts
reporting the -1.#IND00 problem. I tried the _fpreset function to see
if it was a fpu stack poping problem but it doesn't seem to help
either. I also tried global optimizations (/Og) without success.

[snip]

I didn't have time to look at all your code, but on my last project, I
was getting output of something like -1.#J (depending on the width of
the output), but only in Release mode. I found that what happened was
that I was calculating sin() for various values, and due to the
floating-point rounding that was happening in Release mode, my numbers
were like an Epsilon greater than 1.0, so sin() barfed. This did not
happen in Debug mode, I guess because it used slower code that verified
the results of calculations. I was able to fix it in Release mode by
adding an explicit check like:

if (x > 1.0) {
x = 1.0;
}

before taking sin(x).

This may or may not be your problem, but it helped me when I had a
problem with a similar symptom.

--
Marcus Kwok
Mar 15 '06 #3

Marcus Kwok wrote:
Jean-Fran?ois Michaud <co*****@comcas t.net> wrote:
Hello people,

I am rather puzzled by this problem I am having with doubles here. The
code seems to execute correctly for awhile and then all a sudden
printfing out my doubles, I get -1.#IND00 which seems to be an
indeterminate or -infinity or something of the such.

I am coding an IAC network and the problem occurs only in learning mode
when the values approach 1.00 (the values SHOULD stay between between
-0.2 and 1.0, but they occasionally go beyond 1.0 which doesn't make
sense to me either but I'm thinking this is all part of the same
problem.

I do NOT have any sort of division in my program so it can not be a
problem of dividing 0/0 like i've seen mentioned on some posts
reporting the -1.#IND00 problem. I tried the _fpreset function to see
if it was a fpu stack poping problem but it doesn't seem to help
either. I also tried global optimizations (/Og) without success.

[snip]

I didn't have time to look at all your code, but on my last project, I
was getting output of something like -1.#J (depending on the width of
the output), but only in Release mode. I found that what happened was
that I was calculating sin() for various values, and due to the
floating-point rounding that was happening in Release mode, my numbers
were like an Epsilon greater than 1.0, so sin() barfed. This did not
happen in Debug mode, I guess because it used slower code that verified
the results of calculations. I was able to fix it in Release mode by
adding an explicit check like:

if (x > 1.0) {
x = 1.0;
}

before taking sin(x).

This may or may not be your problem, but it helped me when I had a
problem with a similar symptom.


You're the man Markus! This solved the problem ;).

For some obscure reason, the activation goes over 1.0 even though its
supposed to stay below 1.0. Whenever this happens It creates a chain
reaction blowing the netinput per node out of proportion (-infinity,
+infinity) which then affects node activation. I force max activation
back down to 1.0 if it goes over and now everything is smooth.

Thank you much for that!

Regards
Jean-Francois Michaud

Mar 16 '06 #4
> Marcus Kwok wrote:
I didn't have time to look at all your code, but on my last project, I
was getting output of something like -1.#J (depending on the width of
the output), but only in Release mode. I found that what happened was
that I was calculating sin() for various values, and due to the
floating-point rounding that was happening in Release mode, my numbers
were like an Epsilon greater than 1.0, so sin() barfed. This did not
happen in Debug mode, I guess because it used slower code that verified
the results of calculations. I was able to fix it in Release mode by
adding an explicit check like:

if (x > 1.0) {
x = 1.0;
}

before taking sin(x).

Actually in my original example, it was acos() instead of sin(), but
obviously you understood what I meant.

Jean-Fran?ois Michaud <co*****@comcas t.net> wrote: You're the man Markus! This solved the problem ;).


Thanks, but it's Marcus, not Markus. No biggie though :)

--
Marcus Kwok
Mar 16 '06 #5

Marcus Kwok wrote:
Marcus Kwok wrote:
I didn't have time to look at all your code, but on my last project, I
was getting output of something like -1.#J (depending on the width of
the output), but only in Release mode. I found that what happened was
that I was calculating sin() for various values, and due to the
floating-point rounding that was happening in Release mode, my numbers
were like an Epsilon greater than 1.0, so sin() barfed. This did not
happen in Debug mode, I guess because it used slower code that verified
the results of calculations. I was able to fix it in Release mode by
adding an explicit check like:

if (x > 1.0) {
x = 1.0;
}

before taking sin(x).

Actually in my original example, it was acos() instead of sin(), but
obviously you understood what I meant.


Absolutely. For some reason my function poops when I don't explicitly
state a maximum and minum. I don't really think i'll spend more time
figuring it out. It work with the explicit constraint so everything is
good.
Jean-Fran?ois Michaud <co*****@comcas t.net> wrote:
You're the man Markus! This solved the problem ;).


Thanks, but it's Marcus, not Markus. No biggie though :)


Hahah doh. Sorry about that. For some reason k came out instead of c
:).

Regards
Jean-Francois Michaud

Mar 17 '06 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
3054
by: Bruce Davis | last post by:
I'm having a problem on windows (both 2000 and XP) with a multi-threaded tkinter gui application. The problem appears to be a deadlock condition when a child thread pops up a Pmw dialog window in the context of a main window. The problem does not occur on HPUX or Linux. The following simple example code illustrates the problem and the...
11
3739
by: Kostatus | last post by:
I have a virtual function in a base class, which is then overwritten by a function of the same name in a publically derived class. When I call the function using a pointer to the derived class (ClassB* b; b->func(); ) the base-class function is called instead of the new function in the derived class. All other similar functions (virtual in...
117
7113
by: Peter Olcott | last post by:
www.halting-problem.com
28
5183
by: Jon Davis | last post by:
If I have a class with a virtual method, and a child class that overrides the virtual method, and then I create an instance of the child class AS A base class... BaseClass bc = new ChildClass(); .... and then call the virtual method, why is it that the base class's method is called instead of the overridden method? How do I fix this if I...
6
3790
by: Ammar | last post by:
Dear All, I'm facing a small problem. I have a portal web site, that contains articles, for each article, the end user can send a comment about the article. The problem is: I the comment length is more that 1249 bytes, then the progress bar of the browser will move too slow and then displaying that the page not found!!!! If the message is...
16
4882
by: Dany | last post by:
Our web service was working fine until we installed .net Framework 1.1 service pack 1. Uninstalling SP1 is not an option because our largest customer says service packs marked as "critical" by Microsoft must be installed on their servers. Now german Umlaute (ä, ü, ö) and quotes are returned incorrectly in SOAP fault responses. This can be...
2
4536
by: Mike Collins | last post by:
I cannot get the correct drop down list value from a drop down I have on my web form. I get the initial value that was loaded in the list. It was asked by someone else what the autopostback was set to...it is set to false. Can someone show me what I am doing wrong and tell me the correct way? Thank you. In the page load event, I am...
4
16060
by: Thorsten | last post by:
Hi I have a little problem to check a double value. During a multiplication with really small values my result value is set to -1.#IND00. So does anyone knows how I can check the value if it is -1.#IND00? Is there a constant to compare it with? And bye the way, what does this value mean? Thanks for any help Thorsten
3
4563
by: Olumide | last post by:
Hi - I'm computing the angle between pairs of unit vectors as the arc cosine of the dot product of each pair of vectors. Occasionally, when the dot product is 1.000000 (output to 6 decimal places) I get the value -1.#IND00 ! What does this mean? Thanks, - Olumide
0
7665
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7583
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
1
7642
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
7950
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
6255
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
0
5213
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3626
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2082
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1200
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.