Jump to content


Photo

ANNIE


  • Please log in to reply
32 replies to this topic

#1 margoose

margoose

    GMC Member

  • GMC Member
  • 277 posts

Posted 06 September 2010 - 09:28 PM

GMC meet ANNIE (download)...ANNIE meet GMC...


Ok now that we're all acquainted let me describe who ANNIE is:

ANNIE is exactly what her name stands for, an artificial neural network intelligence engine. For those not familiar with the concept basically its a form of fuzzy AI in which takes in input and generates output. ('Ok thats great so does a script, so what...?'). The cool thing about a ANN is that it learns, and in this case when it gives the wrong output you can tell it what the output should have been and it will adjust its calculations. An ANN is not good for coming up with exact,optimal solutions. Instead it is best used for pattern recognition when the pattern isn't exactly clear. So for example you can use it to recognize a number or letter with different fonts, or make predictions based on fuzzy or inexact information. For more information on ANNs visit: http://en.wikipedia...._neural_network and http://en.wikipedia....Neural_networks

Ok, now that we all know what a neural network is let me continue to describe ANNIE. She is a supervised feed-forward ANN that uses backpropagation as the teaching method. She also enjoys long walks on the beach and watching the sunrise over the cit-ay.

Basically she is a set of scripts which allows you to create many different ANNs. You can also connect different ANNs together using the the annie_send_input() function by sending the output of one ANN as another's input. She also currently only accepts binary input and only outputs binary.

'Alright, I really feel like I'm getting to know ANNIE now, but what does she need to have looked at?' Long story short, everything. I started this project simply to understand the basic concepts of how ANNs work. I thought I'd post my work on here in the hopes of the community making it that much better. ANNIE is completely functional as-is, but I don't like the exact algorithm I used in the backpropagation and she doesn't get as accurate as I would have hoped, right now she seems to output quite randomly no matter how many iterations you train her. She needs a save and load function (the current save function is only for human readability). Overall, I am happy with her skeleton, but the details need to be worked out, and I think the community would do a better job than me. Plus, there are many different types of input and outputs that could be possible (integer, decimal, strings, etc) instead of just binary, which requires a completely different algorithm for each one in terms of running and training the network.

Welp, I think thats pretty much it. Have fun ;)

Edited by margoose, 09 September 2010 - 03:26 AM.

  • 1
My Creations:


#2 beeproductions

beeproductions

    Helping gmc users

  • GMC Member
  • 1322 posts
  • Version:GM:Studio

Posted 09 September 2010 - 02:30 AM

Ok..and the download?!!?!?!:)I'm pretty curios about this!
  • 0

col-img1.pngcol-img4.png

bannersig.png

 

 


#3 margoose

margoose

    GMC Member

  • GMC Member
  • 277 posts

Posted 09 September 2010 - 03:31 AM

i made the download link more clear
  • 0
My Creations:


#4 beeproductions

beeproductions

    Helping gmc users

  • GMC Member
  • 1322 posts
  • Version:GM:Studio

Posted 09 September 2010 - 04:13 AM

hehe nice one..but would be much better in more like a real thing:D a simple chat or something like that.IDK but this made me less interested in this..
  • 0

col-img1.pngcol-img4.png

bannersig.png

 

 


#5 margoose

margoose

    GMC Member

  • GMC Member
  • 277 posts

Posted 09 September 2010 - 04:43 AM

yeah I have a lot going on right now, so I was hoping teh community would be able to pick up on where I left off. It needs a touch of genetic computation because right now it is basically using an uphill algorithm which is why it isn't getting as accurate as I'd like. Once it gets a little more accurate I will be able to come up with a better example for it such as a simulated chat bot or something.
  • 0
My Creations:


#6 thatshelby

thatshelby

    GMC Member

  • GMC Member
  • 3823 posts
  • Version:GM8

Posted 09 September 2010 - 05:00 AM

Wow, I was thinking about making a chat bot, which would be fun. Too bad I don't understand NNs.
  • 0

#7 Manuel777

Manuel777

    InvaderGames

  • GMC Member
  • 3578 posts
  • Version:GM:Studio

Posted 25 September 2010 - 03:51 AM

mmmmm i dont get it, shouldnt i set the input values instead of being a random value?
  • 0

@MEtchegaray7

gplussignature.png

May this signature be frozen on the old GMC until the end of times. Or YoYo takes it down.


#8 margoose

margoose

    GMC Member

  • GMC Member
  • 277 posts

Posted 25 September 2010 - 05:24 PM

mmmmm i dont get it, shouldnt i set the input values instead of being a random value?



You can do the inputs however you like...you can have the user define the inputs, the AI can determine the input based on the world around him, or you can randomly generate inputs, what really matters is the output from the input, not how the input gets there. You can even have the output of one neural net be the input of another. What I did in the example is instead of the user defining the input every time I just simulated it with the random function so that you could see what happens over many iterations rather than just a few because it would take to long to do enter the values manually....by using the random generator its like speeding up time because over time the difference between what you would have put and what the computer generates will merge closer and closer to the same output. But remember there are way more useful uses for a neural net than the example I provided does, and neural nets aren't really designed for the example I provided, but I just didn't want to write out an example of recognizing a character or something like that because I am too busy right now.

If you have more questions about it don't be afraid to ask.
  • 0
My Creations:


#9 goldage5

goldage5

    GMC Member

  • GMC Member
  • 152 posts

Posted 13 October 2010 - 09:20 PM

mmmmm i dont get it, shouldnt i set the input values instead of being a random value?



You can do the inputs however you like...you can have the user define the inputs, the AI can determine the input based on the world around him, or you can randomly generate inputs, what really matters is the output from the input, not how the input gets there. You can even have the output of one neural net be the input of another. What I did in the example is instead of the user defining the input every time I just simulated it with the random function so that you could see what happens over many iterations rather than just a few because it would take to long to do enter the values manually....by using the random generator its like speeding up time because over time the difference between what you would have put and what the computer generates will merge closer and closer to the same output. But remember there are way more useful uses for a neural net than the example I provided does, and neural nets aren't really designed for the example I provided, but I just didn't want to write out an example of recognizing a character or something like that because I am too busy right now.

If you have more questions about it don't be afraid to ask.



how mexactly is this used? and what are the practical applications as in a game?
  • 0

#10 margoose

margoose

    GMC Member

  • GMC Member
  • 277 posts

Posted 18 October 2010 - 10:22 PM

how mexactly is this used? and what are the practical applications as in a game?


You can use it however you want to use it. There are many practical applications for neural nets in general but specifically for this community artificial intelligence within a game would be the best use. For example you can use it to write an AI that makes decisions and learns based on inputs. These inputs could be the players health, ammo, and location for example. You could then use those inputs to get a decision output, however you would decide to do that.

and just as a side note, this is open source because it needs further work done on the system its self, it is not 100% ready to go IMO just yet. It does learn over time as the example i provided shows, however.

Edited by margoose, 18 October 2010 - 10:25 PM.

  • 0
My Creations:


#11 jon sploder

jon sploder

    GMC Member

  • GMC Member
  • 919 posts

Posted 22 November 2010 - 04:18 AM

I'm very surprised that this has not received much attention so far. Impressive work, keep it up!
  • 0

#12 rockyrakster

rockyrakster

    GMC Member

  • New Member
  • 20 posts

Posted 29 November 2010 - 03:53 AM

just what i was looking for surprised to find it here!!!!!!!!!Awesome Work!!!
  • 0

#13 margoose

margoose

    GMC Member

  • GMC Member
  • 277 posts

Posted 29 November 2010 - 04:50 AM

Just want to say thanks for the attention, and thanks for the replies

Once I graduate in a couple weeks I will have more time to work on this, as I am still interested in finishing it
  • 0
My Creations:


#14 Rachel

Rachel

    GMC Member

  • GMC Member
  • 128 posts

Posted 06 February 2011 - 02:56 AM

I'd love to see how it works. Could you also post an exe? Since I only have GM7.
  • 0

#15 margoose

margoose

    GMC Member

  • GMC Member
  • 277 posts

Posted 06 February 2011 - 07:30 AM

I'd love to see how it works. Could you also post an exe? Since I only have GM7.

Unfortunately I will not have a computer for sometime so it will be a while before I will be able to do anything except reply on the forums it should be easily converted to gm5 &6 if someone would like to do so...and again I iterate that I have posted this in open source for the community to advance...I am only here to help understand how its programmed...and I used a pseudo-oop style to help in programming and reading the code
  • 0
My Creations:


#16 Eddygp

Eddygp

    Horizhite Games

  • GMC Member
  • 219 posts
  • Version:GM8

Posted 23 June 2011 - 01:17 PM

wow! Thats really good! In the scripts there are only 'for', 'ifs' and arrays, but it works!
  • 1

#17 margoose

margoose

    GMC Member

  • GMC Member
  • 277 posts

Posted 23 June 2011 - 09:39 PM

wow! Thats really good! In the scripts there are only 'for', 'ifs' and arrays, but it works!


Thanks you, I tried to make it as easily readable as possible as there are a lot of nested loops which make in confusing enough when its something of this complexity. Almost anything you need accomplished can be done with those 3 programming techniques. Please look over it and see if u can improve it in any way at all I think its a great gateway to learning about artificial intelligence.
  • 0
My Creations:


#18 jon sploder

jon sploder

    GMC Member

  • GMC Member
  • 919 posts

Posted 24 June 2011 - 06:50 AM

By the way, I've tried this a little bit more today. Feedback (if you're still working on it. Are you?):

If you set the count to 10 rather than 1000, it seems to do just as well for me. So why bother train it so many times?
For debugging purposes, you should perhaps show a message if the program gets the expected outcome wrong, even after it's got it correct say, 10 times.
The switch to convert decimal to binary is probably less effecient than it could be. I can't think of how to convert dec to bin effeciently right now, but I'm sure there are scripts out there. The switch is incredibly slow in GM.
The use of many neuron objects is also very slow for GM. I suggest handling them another way, I mean you've got 16 neuron objects lying around, and although their events aren't executed I'm pretty sure it would be faster without.
I see a save function, but no load function?
I've also noticed that ANNIE picks up the same expected responses, however if it learns 2 it's almost impossible to learn a 3rd. Or even a 2nd occasionally.
  • 1

#19 Eddygp

Eddygp

    Horizhite Games

  • GMC Member
  • 219 posts
  • Version:GM8

Posted 24 June 2011 - 10:43 AM

It would be a good idea to save all the input/output in a DS grid.

Why Grid?
Because it is two dimensional, and could be used to check the input relative to the different outputs with values true or false (which would be then used to load new neurons). Neurons should be able to make connections between themselves, sending integers that would be switched to make information, perhaps. I hope I helped a bit.

Edited by Eddygp, 24 June 2011 - 10:44 AM.

  • 1

#20 margoose

margoose

    GMC Member

  • GMC Member
  • 277 posts

Posted 25 June 2011 - 03:53 AM

Those are great ideas I had some of my own but I lost time while finishing my degree and now I don't have a comp only my droid phone. As for the specific issue of only being able to learn no more than three this is where I was specifically mentioning the need of improvements in its algorithm. I originally thought that the number and/or arrangement of the neurons would fix the issue which is why I had so many but after many moons of testing I could find no optimized layout for the neurons themselves only that u needed at least three to make any decent progress. The less neurons the faster it learns but the less accurate its best outcome is the more neurns the slower it learns but the more accurate the best outcome is. So it learns and it learns correctly the problem is that it has no long term memory, and horrible short term memory, but amazing cognative skills lol.
  • 0
My Creations:


#21 Eddygp

Eddygp

    Horizhite Games

  • GMC Member
  • 219 posts
  • Version:GM8

Posted 25 June 2011 - 08:41 AM

Neurons, in real life, learn by connecting themselves, not only by being more. They connect to transmit information, so I think a set of neurons could connect to another one and, reading a ds_grid, search for the best answer.

EDIT: Not too much neurons: the best output will be searched in the DS grid and then compared to other values:

1- Input
2- Output
3- Expected value
4- Real value

This would make their learning easier and not too many would be needed. Make scripts to connect the neurons. I thought of some variables that determined the connnection.

Edited by Eddygp, 25 June 2011 - 08:45 AM.

  • 1

#22 margoose

margoose

    GMC Member

  • GMC Member
  • 277 posts

Posted 26 June 2011 - 02:15 AM

Real neurons are able to turn their conections on and off and to change a connection from on neuron to another which would be awesome if one could determine the best algorithm/reasons for a neuron to make that change, with that kind of setup you wouldn't need to worry about how u set the neurons up as much because they would handle it themselves over time. /ut to do this you will need completely different scripts even for the initial setup because the script currently atmatically connects every neuron in a previois layer to every neuron in the next like a layered mesh network.
  • 1
My Creations:


#23 Eddygp

Eddygp

    Horizhite Games

  • GMC Member
  • 219 posts
  • Version:GM8

Posted 26 June 2011 - 09:02 AM

Ah... What about input in ds_queues that can be used for ds_grids? Maybe there could be some variables which, er, triggered some codes!
  • 1

#24 margoose

margoose

    GMC Member

  • GMC Member
  • 277 posts

Posted 27 June 2011 - 03:54 AM

I'm not sure input queues would be necessary as it learns on the fly per input unless ur program requires it for somereason but how the input gets there doesn't matter the only thing that matters is what happens as its processing each input. I'm thinking each neuron needs to determine what connections to alter. Real neurons change their connections to the most used neuronsin their surrounding so each artificial neuron should have a min value for their weight so that if its reached then that connection is destroyed or moved to the highest weighted neuron in that layer
  • 0
My Creations:


#25 Eddygp

Eddygp

    Horizhite Games

  • GMC Member
  • 219 posts
  • Version:GM8

Posted 29 June 2011 - 02:09 PM

But they should have like some arrays to search for information and then give the best answer: experience-like arrays.
  • 1

#26 margoose

margoose

    GMC Member

  • GMC Member
  • 277 posts

Posted 30 June 2011 - 03:10 AM

Ur going to have to elaborate a little I think ur a little to focused on the data structure rather than the process come up with a process the the best data structure can be determined but it currently learns off of the error correction within the learn script
  • 0
My Creations:


#27 Eddygp

Eddygp

    Horizhite Games

  • GMC Member
  • 219 posts
  • Version:GM8

Posted 30 June 2011 - 09:02 PM

But at the moment there is not a way to remember things...
  • 0

#28 margoose

margoose

    GMC Member

  • GMC Member
  • 277 posts

Posted 30 June 2011 - 09:17 PM

It does remember things but not the surface way that we think of as remembering...artificial neural networks are for pattern recognition not for exact answer rememberance the idea is for the computer to determine the closest algorithm it takes to get from input to expected output. Sure you could have it just memorized the right answer but that isn't the goal here. In computing you have to choose whether you want to use memory or processing power...would it be more efficient to memorize an infinite table of infintesimal digits for each output or create an algorithm based on the input and calculate it on the fly. This is much more difficult for a human to do when it comes t something like speech or writing recognition or an on the fly path search algoritm than it is for the computer to determine the algorithm itself. But there are many other uses as well but just think of it as creating a method for the computer to generate many different algorithms on the fly based on expected output...now in game you may not know the expected output so the programmer trains the neural net then wen the customer plays the game without learning. Of course if you can determine a way in game to have it find what the right output should have been after the decision was made then you could teach it that way in game. There really is no limit in theory.
  • 0
My Creations:


#29 Eddygp

Eddygp

    Horizhite Games

  • GMC Member
  • 219 posts
  • Version:GM8

Posted 01 July 2011 - 08:54 AM

Well, but it would be quite difficult, e.g., to modify it to recognise the Fibonacci numbers, which are a pattern.

Edited by Eddygp, 01 July 2011 - 08:54 AM.

  • 0

#30 margoose

margoose

    GMC Member

  • GMC Member
  • 277 posts

Posted 02 July 2011 - 10:42 PM

Not exactly what i meant by pattern recognition, neural nets are fuzzy math for fuzzy patterns not set patterns think different handwriting input from different people and trying to come with the same output. I reread some of the other posts as well and it seems there is a bit of confusion as to how it works currently:

- Each neuron is connected to every neuron in the next layer
- Each neuron sends the same output to each neuron its connected to
- Each neuron calculates its output via an multiplication of an initial number and all its inputs and corrects that number via error detection.


Current Problem: The error detection that I think should be used makes all outputs eventually go to zero so my logic is wrong somewhere. The logic I use is:

error = expected_output - actual_output;

If I set all of the errors to this then the zero problem occurs. This is the major issue with its learning as far as I can tell.


edit: It can be used to learn an exact pattern but the biggest issue with that is that there is no gaurantee that it will be exact with any and every input at any given time due to the nature of the learning progression and curve.

Edited by margoose, 02 July 2011 - 11:05 PM.

  • 0
My Creations:


#31 Eddygp

Eddygp

    Horizhite Games

  • GMC Member
  • 219 posts
  • Version:GM8

Posted 03 July 2011 - 08:56 AM

Are you checking the output in binary? THen, you could make a simple code to check it. I'll see if I have one here...
  • 0

#32 margoose

margoose

    GMC Member

  • GMC Member
  • 277 posts

Posted 04 July 2011 - 02:27 AM

Well each neuron in the output layer always outputs a 1 or a 0 so its really the only way to check it directly so yes. What the example I made using the scripts is supposed to do is learn how to reverse the input so that 111001 outputs 100111. I did this because its a more dfficult algorithm than simply doing a bitwise operation and I wanted to test the waters but I got less than I expected due to the problem listed in my above post. Try using the scripts on an easier algorithm and see if it gets better results.

And remember it learns through back propogation there's a link in the first post. I tried the algorithm that they listed but I don't think I understood it correctly if someone with a better eye for math symbols wants to give it a shot please feel free. Also feel free to add other features as well.

FInally, I WANT TO STRESS THE FOLLOWING: that I am not making much advances to this myself unless I feel like it, I've done what I wanted. I am here to HELP others interested in UNDERSTANDING the code I wrote and the processes involved and I do not want this to turn into a help me solve these issues, this is a ill help you solve these issues if you want to learn. Please do not post general ideas about how it might be fixed and expect me to figure it out because its not gonna happen. If you post general ideas I will give feedback on how the code works and why and how something in that general area will be useful or completely out in left field somewhere and why. The best and most useful posts will be about any advances you've made to it and discussions based on those advances. That is all, thank you!
  • 0
My Creations:


#33 jon sploder

jon sploder

    GMC Member

  • GMC Member
  • 919 posts

Posted 27 August 2011 - 05:26 AM

Alright, I've been talking with margoose over the last few weeks and he's helped me a lot to update ANNIE:

Revisions/Modifications:

Base 10 to Binary conversion script now instead of a switch.
Picked up a irandom(10)-1 bug, irandom starts at 0 now, I think it changed, so this threw out
negative (1) values occasionally.
Added local variable declarations of some forgotten things.
A few additional comments.
Returns correct absolute error of network now, along with more detailed feedback.
Added a graph that displays the gross amount of errors that are in that 'step' of training the
network. 0 errors are ideal, the larger the spike on the graph, the worse it is. The network
should show a trend to graph downwards if it is truly making progress.


Check the game information for extremely important notes.

http://www.box.net/s...rue8fy6f38dszmt

If I continue trying to update ANNIE, I'm going to focus on the following:
A bit more visual debugging representation, eg graphing longer results (the graph scripts were poorly written in a short time).
Changing the error threshold problems that margoose and I have recently seen, but of course it's easier said than done.
  • 0