void Start() { observation_inputs = new List <float[, , ]>(); decision_outputs = new List <float[]>(); decision_weights = new List <float>(); evalSolver = Noedify.CreateSolver(); // PlayerPrefs.DeleteAll(); rdb = gameObject.GetComponent <Rigidbody>(); }
void Start() { trainingSolver = Noedify.CreateSolver(); trainingSet = new List <Hoppy_Brain.PlayerObservationDecision>(); BuildNetwork(); no_players = 1; ChangeNoPlayers(false); lastObstacleSpawn_t = -obstacleSpawnTime; topScore = 0; }
// Start is called before the first frame update void Start() { if (simController == null) { simController = GameObject.Find("SimController").GetComponent <Hoppy_SimController>(); } observation_inputs = new List <float[, , ]>(); decision_outputs = new List <float[]>(); decision_weights = new List <float>(); lastMovement_t = -decisionPeriod; evalSolver = Noedify.CreateSolver(); modifiedDecisionPeriod = decisionPeriod; }
public void TrainModel() { List <float[, , ]> trainingData = new List <float[, , ]>(); List <float[]> outputData = new List <float[]>(); List <Texture2D[]> MNIST_images = new List <Texture2D[]>(); MNIST_images.Add(MNIST_images0); MNIST_images.Add(MNIST_images1); MNIST_images.Add(MNIST_images2); MNIST_images.Add(MNIST_images3); MNIST_images.Add(MNIST_images4); MNIST_images.Add(MNIST_images5); MNIST_images.Add(MNIST_images6); MNIST_images.Add(MNIST_images7); MNIST_images.Add(MNIST_images8); MNIST_images.Add(MNIST_images9); Noedify_Utils.ImportImageData(ref trainingData, ref outputData, MNIST_images, true); debugger.net = net; Noedify_Solver.SolverMethod solverMethod = Noedify_Solver.SolverMethod.MainThread; if (solverMethodToggle != null) { if (solverMethodToggle.isOn) { solverMethod = Noedify_Solver.SolverMethod.Background; } } if (solver == null) { solver = Noedify.CreateSolver(); } solver.debug = new Noedify_Solver.DebugReport(); sw.Start(); //solver.costThreshold = 0.01f; // Add a cost threshold to prematurely end training when a suitably low error is achieved //solver.suppressMessages = true; // suppress training messages from appearing in editor the console solver.TrainNetwork(net, trainingData, outputData, no_epochs, batch_size, trainingRate, costFunction, solverMethod, null, 8); float[] cost = solver.cost_report; StartCoroutine(PlotCostWhenComplete(solver, cost)); }
void Start() { trainingSolver = Noedify.CreateSolver(); trainingSet = new List <Hoppy_Brain.PlayerObservationDecision>(); BuildNetwork(); }
Noedify.Net BuildAndImportModel() { modelImportComplete = false; int no_labels = 10; bool importTensorflowModel = false; net = new Noedify.Net(); // Attempt to load network saved as a binary file // This is much faster than importing form a parameters file bool status = net.LoadModel("Noedify-Model_Digit_Drawing_Test"); if (status == false) { print("Binary file not found. Importing Tensorflow parameters."); importTensorflowModel = true; } // If the binary file doesn't exist yet, import the parameters from the Tensorflow file // This is slower, so we will save the network as a binary file after importing it if (importTensorflowModel) { /* Input layer */ Noedify.Layer inputLayer = new Noedify.Layer( Noedify.LayerType.Input2D, // layer type new int[2] { 28, 28 }, // input size 1, // # of channels "input layer" // layer name ); net.AddLayer(inputLayer); // Hidden layer 0 Noedify.Layer hiddenLayer0 = new Noedify.Layer( Noedify.LayerType.FullyConnected, // layer type 600, // layer size Noedify.ActivationFunction.Sigmoid, // activation function "fully connected 1" // layer name ); net.AddLayer(hiddenLayer0); // Hidden layer 2 Noedify.Layer hiddenLayer1 = new Noedify.Layer( Noedify.LayerType.FullyConnected, // layer type 300, // layer size Noedify.ActivationFunction.Sigmoid, // activation function "fully connected 2" // layer name ); net.AddLayer(hiddenLayer1); // Hidden layer 2 Noedify.Layer hiddenLayer2 = new Noedify.Layer( Noedify.LayerType.FullyConnected, // layer type 140, // layer size Noedify.ActivationFunction.Sigmoid, // activation function "fully connected 3" // layer name ); net.AddLayer(hiddenLayer2); /* Output layer */ Noedify.Layer outputLayer = new Noedify.Layer( Noedify.LayerType.Output, // layer type no_labels, // layer size Noedify.ActivationFunction.Sigmoid, // activation function "output layer" // layer name ); net.AddLayer(outputLayer); net.BuildNetwork(); status = NSAI_Manager.ImportNetworkParameters(net, "FC_mnist_600x300x140_parameters"); if (status) { print("Successfully loaded model."); } else { print("Tensorflow model load failed. Have you moved the \"...Assets/Noedify/Resources\" folder to: \"...Assets/Resources\" ?"); print("All model parameter files must be stored in: \"...Assets/Resources/Noedify/ModelParameterFiles\""); return(null); } net.SaveModel("Noedify-Model_Digit_Drawing_Test"); print("Saved binary model file \"Noedify-Model_Digit_Drawing_Test\""); } solver = Noedify.CreateSolver(); solver.suppressMessages = true; modelImportComplete = true; return(net); }