public void Save() { NNetData data = new NNetData(net); SaveSystem.Save(Application.persistentDataPath + "/net.dat", data); Debug.Log("Saved successfully!"); }
public void Initialize(NNetData data) { structure = data.structure; random = data.random; mutateChance = data.mutateChance; structureLength = structure.Length - 1; // Initialize weights weights = new double[structureLength][][]; for (int layer = 0; layer < structureLength; layer++) { biasesLength = structure[layer]; weights[layer] = new double[biasesLength][]; for (int node = 0; node < biasesLength; node++) { weightsLength = structure[layer]; weights[layer][node] = new double[weightsLength]; for (int weight = 0; weight < weightsLength; weight++) { weights[layer][node][weight] = random.NextDouble() * random.Next() == 0 ? 1 : 1; } } } // Initialize biases biases = new double[structureLength][]; for (int layer = 0; layer < structureLength; layer++) { biasesLength = structure[layer + 1]; biases[layer] = new double[biasesLength]; for (int node = 0; node < biasesLength; node++) { biases[layer][node] = random.NextDouble() * random.Next() == 0 ? 1 : 1; } } structureLength = structure.Length; // Initialize Next cache nextCalculations = new double[structureLength][]; for (int layer = 0; layer < structureLength; layer++) { nextCalculations[layer] = new double[structure[layer]]; } }
public void save(string path) { NNetData netData = new NNetData(this); SaveSystem.Save(path, netData); }