this isnt working, i think it has something to do with the natural exponential, its a calculation of the sigmoid function. it basically should read

1/(1 + e^-((W1A*pix1)+(W2A*pix2)))

this is what ive coded

``OUTA = 1/(1 + exp -((W1A * pix1) + (W2A * pix2)));``

2
Contributors
8
Replies
9
Views
10 Years
Discussion Span
Last Post by 666kennedy

your code needs to call pow() to raise x to the power of y. Don't know what exp is in your code.

exp is meant to represent the natural exponential, is how it is represented in every other electronic form ive met, i just assumed c++ would be the same, how would i incorporate this pow() in the code provided

It's just a simple function call. Read this:. The paramter [x] would be the value of e (whatever that is) and the paramter y is the calculation `-((W1A * pix1) + (W2A * pix2)));`

thank you, helped lots, i just assumed that there was a symbol for the natural exponential in c++.

i am also creating random numbers for each weight.

``````float W1A =  -1 + rand() / ( RAND_MAX / ( 1 + 1 ) + 0.1 );
float W1B =  -1 + rand() / ( RAND_MAX / ( 1 + 1 ) + 0.1 );
float W2A =  -1 + rand() / ( RAND_MAX / ( 1 + 1 ) + 0.1 );
float W2B =  -1 + rand() / ( RAND_MAX / ( 1 + 1 ) + 0.1 );``````

but every time i compile and run the program the same numbers come up. how can i make it create a new set of numbers each time.

you need to seed the random number generator. Most people see it with the current clock time of the computer

``````#include <ctime>

...
srand( time(0) );``````

Depending on your compiler you may need to typecast the return value of time() to size_t.

i dont quite understand, but thats purely down to my knowledge of c++ i really am a beginner so sorry and i thank you for your patience, basically my system runs through and stops, i exit the console and if i want to run through it again i compile and run it again. so for everytime it runs through i want it to produce a different set of numbers. is that what this will do, how would i impliment it, what would x be in time(x)?

I already showed you the code to do it. Just paste that line after main().

``````#include <ctime>
// other includes here

int main()
{
srand( time(0) );
// other code here
}``````

The time() function gets the current system time in seconds since 1970. So every time you run the program time() will return something different.

thanks bud, thats perfect, i dont think ill use it til the end so i can use the numbers to calculate the outcomes by hand too. anyway thanks so much. ill be asking another question soon, but not on this thread, as it is a different topic