Programming a neural network

The best way to learn something is to do it, so in this section, we will write a simple neural network that we'll then train to perform various tasks. This network will have a set number of layers—input, hidden, and output—but we will allow for a number of neurons to be set in each layer. We will write this code in Unity so that we can use it in Chapter 10Mixing in Mixed Reality.

Writing a neural network is an advanced example, which will require a discussion with math to properly explain. If you feel overwhelmed at any time, you can always open up the finished project and check the final results. Of course, if you have written a neural network earlier, then you may also want to skip this section.

For this example, we will create a new project from the source Unity template, so let's get started by opening Command Prompt:

  1. Create a new folder called ARCore off the root (C: on Windows) folder using the following commands:
mkdir ARCore
cd ARCore
  1. This set of commands creates a new folder and then navigates to it.
  2. Execute the following command:
git clone https://github.com/google-ar/arcore-unity-sdk.git ARCoreML
  1. This pulls the Unity ARCore template from GitHub into a new folder called ARCoreML.
  1. Open a new instance of Unity and click on Open on the Project page. This will open the select project folder dialog. Select the new folder you just pulled the template into, ARCoreML, to open the project. Wait as the project opens in the Unity editor.
  2. Right-click on (Ctrl + Click on Mac) the Assets folder in the Project window. Select Create | Folder from the context menu. Name the new folder Scripts.
  3. Open the HelloAR scene from the Assets/GoogleARCore/Examples/HelloAR folder by double-clicking on it in the Project window.
  4. From the menu, select File | Build Settings. Ensure that Android is set for the target platform and the HelloAR scene is set as scene 0 in the build.
  5. Connect your device and build and run. Just ensure that the example runs as you expected on your device.
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.218.212.102