Jump to content
  • Advertisement
  • 04/04/18 02:30 AM

    Neural Networks
    Neural Networks 101

    Artificial Intelligence
       (1 review)

    mrsaturn01

    Intention

    This article is intended to give a brief look into the logistics of machine learning. Do not expect to become an expert on the field just by reading this. However, I hope that the article goes into just enough detail so that it sparks your interest in learning more about AI and how it can be applied to various fields such as games. Once you finish reading the article, I recommend looking at the resources posted below. If you have any questions, feel free to message me on Twitter @adityaXharsh.

    How Neural Networks Work

    Neural networks work by using a system of receiving inputs, sending outputs, and performing self-corrections based on the difference between the output and expected output, also known as the cost.

    Neural networks are composed of neurons, which in turn compose layers, or collections of neurons. For example, there is an input layer and an output layer. In between the these two layers, there are layers known as hidden layers. These layers allow for more complex and nuanced behavior by the neural network. A neural network can be thought of as a multi-tier cake: the first tier of the cake represents the input, the tiers in between, or lack thereof, represent the hidden layers, and the last tier represents the output.

    The two mechanisms of learning are Forward Propagation and Backward Propagation. Forward Propagation uses linear algebra for calculating what the activation of each neuron of the next layer should be, and then pushing, or propagating, those values forward. Backward Propagation uses calculus to determine what values in the network need to be changed in order to bring the output closer to the expected output.

    Forward Propagation

    ann_3.gif

    As can be seen from the gif above, each layer is composed of multiple neurons, and each neuron is connected to every other neuron of the following and previous layer, save for the input and output layers since they are not surrounding by layers from both sides.

    image.png.2b7512473ace465ef5940279ed53e798.png

    To put it simply, a neural network represents a collection of activations, weights, and biases. They can be defined as:

    • Activation: A value representing how strongly a neuron is firing.
    • Weight: How strong the connection is between two neurons. Affects how much of the activation is propagated onto the next layer.
    • Bias: A minimum threshold for whether or not the current neuron's activation and weight should affect the next neuron's activation.

    Each neuron has an activation and a bias. Every connection to every neuron is represented as a weight. The activations, weights, biases, and connections can be represented using matrices. Activations are calculated using this formula:

    activ.thumb.png.68eafd5e469e68652f7ddc3762b3524b.png

    After the inner portion of the function has been computed, the resulting matrix gets pumped into a special function known as the Sigmoid Function. The sigmoid is defined as:

    sig.png.e58b7637466f1e2b3a6f2dfe5d1c8fd1.png

    The sigmoid function is handy since its output is locked between a range of zero and one. This process is repeated until the activations of the output neurons have been calculated.

    Backward Propagation

    The process of a neural network performing self-correction is referred to as Backward Propagation or backprop. This article will not go into detail about backprop since it can be a confusing topic. To summarize, the algorithm uses a technique in calculus known as Gradient Descent. Given a plane in an infinite number of dimensions, the direction of change that minimizes the error must be found. The goal of using gradient descent is to modify the weights and biases such that the error in the network approaches zero.

    engineeronadisk-12.gif

    Furthermore, you can find the cost, or error, of a network using this formula:

    image.thumb.png.c8a0b7acacd5acdf9c12a6cd03c13e4e.png

    Unlike forward propagation, which is done from input to output, backward propagation goes from output to input. For every activation, find the error in that neuron, how much of a role it played in the error of the output, and adjust accordingly. This technique uses concepts such as the chain rule, partial derivatives, and multi-variate calculus; therefore, it's a good idea to brush up on one's calculus skills.

    High Level Algorithm

    1. Initialize matrices for weights and biases for all layers to a random decimal number between -1 and 1.
    2. Propagate input through the network.
    3. Compare output with the expected output.
    4. Backwards propagate the correction back into the network.
    5. Repeat this for N number of training samples.

    UnsteadyUnkemptKangaroo-size_restricted.

    Source Code

    If you're interested in looking into the guts of a neural network, check out AI Chan! It's a simple to integrate library for machine learning I wrote in C++. Feel free to learn from it and use it in your own projects.

    https://bitbucket.org/mrsaturnsan/aichan/

    Resources

    http://neuralnetworksanddeeplearning.com/

    https://www.youtube.com/channel/UCWN3xxRkmTPmbKwht9FuE5A

     

     



      Report Article


    User Feedback


    There are no comments to display.



    Create an account or sign in to comment

    You need to be a member in order to leave a comment

    Create an account

    Sign up for a new account in our community. It's easy!

    Register a new account

    Sign in

    Already have an account? Sign in here.

    Sign In Now

  • Advertisement
  • Advertisement
  • Latest Featured Articles

  • Featured Blogs

  • Popular Now

  • Similar Content

    • By Iris_Technologies
      I had some doubts about hex formats(assembler output) and linkers:

      1.- So, I disassembly a raw binary(no ELF, PE, etc... headers) X64 assembly code and i got that result:

       
      0: 66 89 c8 mov ax,cx 3: e8 00 00 00 00 call 8 <gh> 0000000000000008 <gh>: 8: 66 89 c2 mov dx,ax I understand how Byte Offset works('66' is the byte ID 0, '89' is 1, 'c8' is 2 and on 3 the call instruction starts(that is why '3:' is there)) but, by that logic, shouldn't 'call gh' be translated to 'e8 00 00 00 00 00 00 00 08' instead of 'e8 00 00 00 00' since the byte offset of the first instruction of gh, which is 'mov   dx, ax' is 8 and the output is 64 bits?
       
      2.- Using the example of above, if endianness is little end., how the assembler would swap the bytes, by each instruction? Like:

       
      Original, no endiannes { 66 89 c8 e8 00 00 00 00(in case that would be correct and i'm wrong in the question 1.-) 66 89 c2 } to { c8 89 66 00 00 00 00 e8 c2 89 66 } 3.- And then, the big end. would be like the original, without endiannes, code of the question 2.-?
      4.- Suppose that i mark gh as .globl, then, would the assembler create a map table file where gh is in 'e8 00 00 00 00'(again, in case that would be correct and i'm wrong in question 1.-), and linker will look into such map file, and if another object file calls gh, the linker will then translate call gh as either 'e8 00 00 00 00'?
    • By White_crow
      What is Horror?  Horror is a work that causes a person to feel fear; a feeling induced by perceived danger or threat.  But people have greatly evolved and modern people are sometimes more afraid of taxes than real dangers!
      All horror games can be divided into psychological or non-psychological horror games. This is not an indicator of quality, but only the method of frightening a person.  Non-psychological horror games can be very good games, and psychological may well be bad.  Let's see what the difference is between them.
      Non-psychological horror games use our primitive fears such as fear of pain and death. These games frighten the player during the game.
      This includes survival horror, action horror, stealth horror, simple screamers and much more.  In such games for the life of the game character in the game, there is a direct danger. But the problem is that a person has a mental barrier that turns on during the game. The game needs to break through this barrier in order to scare the player.
      To break through the barrier using three methods: flow, pressure, and payback.   Each of the methods greatly affects the gameplay.
      Flow
      Flow is one of the reasons why new horror scolds for the fact that the game has more become an action game than a horror. But here it is necessary to understand the developers want to create a good horror game and using this principle is not bad. It's just very difficult to balance it. Developers try to create an endless action in which the boundaries between themselves and the character will blur.  To do this, the player is given a huge number of tasks, the player concentrating on these tasks gradually removes the mental barrier, as a result, unexpected events do start to have effects on the player.
      Good examples: dead by daylight, deceit.
      Pressure
      Pressure is one of the reasons why most monsters in new projects are either unrecognizable or unresponsive to any player's actions. The skills of players are growing. Now it's hard to find the level of difficulty for the players. The computer is predictable, and if the monster in the game can be destroyed, then the game becomes easy for a large part of the audience. So the developers went to the trick. Now most of the monsters are immortal, and even if they are still so stupid by the standards of the player, now they really begin to create complexity for the player. If you manage to make the monsters smarter the game will really scare the player.
      Good examples:  Alien: Isolation, SCP.
      Payback
      Payback - adds extra weight to our failure. The player begins to fear not death in the game, but the result of death, punishment. The further the player passes and receives more, the greater the weight becomes on the shoulders of the player, and the stronger the player begins to fear defeat. The player can lose all the progress of the game, or lose all his equipment.
      Good examples: Zombiu, DayZ.  
      Psychological Horror
      Psychological horror uses our subconscious fears: loneliness, sanity of mind, punishment, correctness of choice. These games lay in the player certain thoughts that start to frighten the player behind in the real world.
      There are two methods of creating psychological horror: creation and awakening.
      Awakening is a method during which one of the person's subconscious conflicts will awaken. Because of this method, many games that are basically the usual horror are called psychological. Since this method can be modular and used in just a couple of moments. This method is easy to use. And he bases on a lot of psychological principles, which is the norm for most people.
       Awakening uses such principles: knowledge and understanding, powerless, uncanny valley, disorientation, fishy, against the mirror. 
      Knowledge and understanding - Part of good horror is a mystery. The player has too little information, or the person is not able to understand this information. Powerless - The main character is weak and insignificant. He is not able to do anything or change anything. Caught in a whirlpool of events, that is much more of a player. The player turns into an involuntary observer in order. Lovecraft loved to use this principle in his works. Uncanny valley – Human consciousness is very stereotyped. So we deceive the player. Breaking these stereotypes and forcing the player to doubt his own sanity. This principle works in two ways: looks and functional. Looks. If there is something with which you are well acquainted, and will be changed a little. If the change is insignificant and it cannot be found unless specifically looked for it. Then the player will have a strange sense of paranoia and fear. After all, although the player deliberately did not notice the difference, subconsciously the mind noticed everything and began to sound the alarm.   Functional . If something looks like a mug, then it's a mug, not an alien killer. Until one day you do not fall into an alien killer disguised as a mug. You are used to the fact that bullets do damage to enemies. But that if among the bullets there are blank bullets. Disorientation – Disorientation is based on our standard perception of the world: time, space and gravity. Any manipulation of time, space confuses the perception of the world in the player disorienting and frightening him. The first part of the "Evil within" is almost completely built on this principle. Fishy - This principle works in contrast to the Uncanny valley. The human brain reacts very peculiarly to events, and if events that seem unlikely or impossible to our mind suddenly occur, then our brain starts to believe that something is wrong. Imagine that you were kidnapped. You come to consciousness in a locked warehouse with 30 more people. Everyone starts to communicate and it turns out that everyone in the room is called Larry and only you have a different name. Even if it's just a coincidence, this fact scares you much more than the fact of abduction itself. Against the mirror – The principle in which a player is forced to meet the result of his actions.  The player does something that he thinks is right or something that the game asks for. Then he meets with the consequences of his actions. Examples of good games with this principle: spec ops the line, undertale, silent hill. Loneliness – The player is isolated from other people or the outside world.  If you simply use these principles without context, then it will lead to nothing. But awakening in good hands can be extremely powerful. Let's look at PT and what it uses.
      Constant return to the same room. This is the principle of disorientation. At every entry in the room the room changes. Using the Uncanny valley. At some point the radio will ask the player to turn around.. Fishy principle. The game has no background. And the player learns all the information from the environment and the radio. The principle of knowledge and understanding. The player is not able to do anything against the ghost. The principle of powerless. Creation
      You work from scratch. You do not know what the man is afraid of. But taking as a basis a person who has a specific fear (phobia). Taking his experience, the cause and vision of the world under the influence of this fear. You create this fear for the player from the very beginning. Create a world and experience in which this fear really matters.
      Examples of phobias and how to turn them into a game:
      Acrophobia – Imagine a game where the player needs to cross the skyscrapers along the rope. And in case of a fall you will fly to the end down. Apiphobia – Imagine a game where all the bees went crazy and made a real apocalypse. Completely exterminating all people and nurturing the nests everywhere including the bodies of men. And throw the player to survive in this. No worse than a zombie apocalypse. Haptophobia – The game character gets injured in every physical encounter with any person. Now you need to get out of the huge metropolis on foot. All residents go about their business and do not pay attention to you. And only you need to avoid the clash with people.
    • By White_crow
      Game design starts with an idea ... But at the same time I did not find a single course or book where it would be talked about how to generate ideas and how to do it better. I spent some time studying the question, and I identified four techniques that can be used by the game designer in creating ideas. There are, of course, more techniques, but many of them are designed to solve problems than to generate ideas.
      The techniques are called: Concentration, Brain Storm, Scamper and Ramsey.
      Concentration
      This method is the most common and we are all able to use it ourselves, without any training. In fact, you think until you have an idea.
      But in this case, too, has its own characteristics, which I learned from one biochemist, named Motonari Uesugi, who had a course in biochemistry.
      He talked about a scientist who developed DNA cloning. The road to the research center, where the scientist worked, was walking along a rocky, winding road running along the shore of the ocean. Every day, on the way to work and from the work of a scientist, a lot of excellent ideas were visited, while at the same time he could not come up with anything at work. He put forward the assumption that thinking in a stationary atmosphere a person will always come to the same ideas, but being in a changing atmosphere a person will generate constantly different ideas.
      Further research has shown that any changes in the environment affect positively the generation of ideas: To ride an unknown route, take a walk in an unusual time for you and so on. Further it turned out that not only the change of environment influenced the generation of ideas, but also any new information was obtained. Therefore, curious people that are constantly learning something new can generate ideas better. Therefore, for the game designer, curiosity and constant study of something new are vitally important.
      Brainstorm
      It is the most common and well-known method in the industry. Many companies use this method and this is the only method that I learned about from the games industry.
      To perform this method, only people (10-20) and premises are needed. The method is performed in 3 stages. People are divided into two groups: Participants and the Commission.
      The first stage is "Statement of the task".
      It is held by the participants. In the case of creating games, the task is issued from the number of resources: the amount of money, the number of team members and their specialization, the amount of time to develop. All the collected information on resources can adequately create an idea of what kind of project the team can create.
      The second stage is the "Generation of Ideas".
      It is held by the participants. People simply begin to offer and complement each other's ideas. Any ideas are collected, even the most delusional ideas, for example: a plumber saving a princess or a super fast blue hedgehog. When all the ideas are collected they are transferred to the third stage.
      The third stage is "Grouping and selection."
      It is held at the commission. Here already the second group collected ideas evaluates and chooses the best idea.
      For this method it is important that the group of people for the brainstorming be as diverse as possible. Therefore, many companies also strive to collect a diverse team (different races, nationalities, social status, history, gender). Also, if participants in the assault team are members of the game development team, the idea and concept of the game will be perceived as the result of the collective work of the team. This improves the atmosphere in the team and will increase the motivation of team members.
      Scamper
      It is very simple and convenient method. It is especially useful when working with unusual and unloved types of games for you. It is very easy to use and almost always brings results. In fact, this is not one method, but a whole set of methods that the game designer changes in turn, until he finds his idea. Each of the letters is a reference to one of the methods of generating ideas. In this case, it is better to disassemble each of the methods separately.
      Substitute
      Replace. You simply replace something in an existing project and see how everything will look now. In the case of games, you need to change the mechanics in the game.
      Think: What if I replace it?
      Example: Noitu love 2
      In this game there are three game characters that open in their time. The plot game and most levels are the same for all characters. But by including games for different characters, the game begins to be felt completely differently. The reason for this is the different mechanics of each of the characters.
      Sometimes, it seems that these are different games, although the levels and behavior of the enemies remained the same. I can talk a lot about this topic, but it will be better if you sit down and try it yourself.
      Combine
      Combine. You take two genres that already exist and try to mix them together.
      Think about it. What if you take these two or more genres of games and cross?
      Example: Borderland.
      This series of games is a combination of shooter and RPG. From the shooter game got a first-person view and the main combat mechanics. From RPG the game got a level system, experience, pumping, all sorts of equipment with different indicators and special abilities that a player can learn and use in combat.
      Adapt
      Adapt. To do this, you take existing old and forgotten mechanics and update them to new technologies and time.
      Think about it. What old mechanics can I use? Where to use it? And how will this mechanic change?
      Example: AR and old educational games.
      We all know the game Pokemon GO. But few people know that the mechanics, on which it is based, was created long before the advent of mobile phones. Eric Klopfer talked about an educational game that used maps and real places for learning. But this mechanics did not find its popularity because of its inconvenience. But over time, there were mobile devices that could use this mechanic without unnecessary problems. Since 2012, this mechanics has returned with the name Augmented Reality.
      Modify
      Edit. Here you refer all the games with a change in the aesthetics and level of the objects of the game. Unlike "replace" here the aesthetics of the game changes more than its mechanics.
      Think about it. What if you make such a game about something bigger or something less, perhaps something else?
      Examples: The Sims and SimCity.
      In the first case, we have a simulator for managing the family of people and their dwelling, and in the second, a simulator controlling the city and its inhabitants. The concept of the game has remained the same, it is an economic and spatial simulator. The difference in games is only in the levels of objects: in the first case it is only a house with a small family, and in the second it is a city.
      Put
      Apply. You simply take the existing mechanics and find a new application for it.
      Think about it. How else can you use this mechanics?
      Example: Undertale.
      In the case of Undertale there is a system of experience and levels, but it has a completely different meaning than in other games. If in most games these indicators show the power and development of the character during the game, then in this game this mechanics and characteristics is the player's karma.
      Eliminate
      Exclude. This method requires the game designer to cut and exclude some mechanics in the already existing type of games.
      Think about it. What can be cut out of the game and how will it work then?
      Example: Ultimate Epic Battle
      We all know the strategists: we collect resources, build the base, build the army, destroy the enemy army, destroy the enemy base and win. But if we exclude everything related to the collection of resources, construction and development base. What's left? And there will be Ultimate Epic Battle, here you just generate armies on the battlefield and watch them fight.
      Reverse
      Expand. The games industry is also flexible to the action of stereotypes, like any other information sphere. And sometimes breaking these stereotypes can get very interesting projects.
      Think about it. What if we do not do here like everyone else? What if we did the opposite?
      Example: Overlord and dungeon keeper.
      In most fantasy games, the main character is a positive character saving the world from evil. In the same games you had to play for the villain. What made them much more interesting than most other projects in fantasy style.
      The Ramsey method.
      This is the most difficult of the methods. This method was taught to me by psychologists and for this reason it is so complex and heavily populated. But you will need it, too, if you want to become a high-class specialist. What is this method for? One day you will be hired as a game designer and your director will say to create a game on a very specific topic, for example, to create a game about Einstein, fairy tales of the Brothers Grim, or "Alice in Wonderland". And you immediately rested against the wall.
      Ramsey wrote a theory that, if you take a large amount of information and start looking in it closely and manically, you can find new information or find inconspicuous links. This explains why people with various psychological disorders, like paranoia and schizophrenia, can everywhere find evidence of their rightness and their theories. This theory can also be used in the opposite direction, creating previously unobtrusive concepts at first glance.
      The essence of this method is that you collect the maximum amount of information on the topic that you need to assemble the games. And then you start to study this information, looking for hidden connotations and imperceptible connections in it until the concept of the game is collected from these pieces. The effectiveness of this method depends only on two factors: the amount of information collected and the effort spent studying this information.
      Let me give you a couple of examples.
      The game about Einstein is Brad. Two years after I played the game, I accidentally took the book "Einstein's Easy Lessons". My brain just exploded, many moments, phrases and mechanics were described throughout the book.
      The game about the Brothers Grimm - American McGee's Grimm. In the beginning, I did not understand why in these games the twisting and dullness of fairy tales. But then I met one person. He told me that the fairy-tale brothers' tales have changed a lot since that time they were in the original. It was darker times and tales, respectively, were much gloomier, but over time, adaptation of fairy tales to a new time was in progress. As a result, after reading the original tales of the brothers' make-up and the current editions, the person will have a vivid sense of contrast. This is shown in the game. This is a sense of contrast between what we know these fairy tales and what they really were written.
      The game about "Alice in Wonderland" - American McGee's Alice and Alice: Madness Returns.
      In the game you will meet most of the characters from the book, and you will visit Wonderland. The game designer tried to imagine what happened to the main character, so that Wonderland appeared in her head. For the main character, Wonderland is the inner world of her mind. As a result, the story began to consist not only of events in Wonderland, but also the events of real life, which is mirrored in the Wonderland of Alice.
      As you have noticed, most of such a game plan can be called unusual and sometimes strange, which does not make them bad. So if your director wants to create a game based on his favorite music group or his favorite book, now you know what to use.
      This is my first article and I hope that it has been useful to you.
  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!