public void Initialize(MendelMachine mendelMachine, Genoma genoma, ActivationFunction activationFunction, bool learningPhase, float lifeTime, int index) { fitness = 0; this.activationFunction = activationFunction; this.index = index; this.mendelMachine = mendelMachine; this.learningPhase = learningPhase; this.lifeTime = lifeTime; perceptron = new Perceptron(genoma, activationFunction); }
void Start() { if (!learningPhase && !string.IsNullOrEmpty(brainPath)) { try { FileStream fs = new FileStream(brainPath, FileMode.Open); BinaryFormatter formatter = new BinaryFormatter(); perceptron = new Perceptron(new Genoma((LinearAlgebra.Matrix[])formatter.Deserialize(fs)), activationFunction); fs.Close(); Debug.Log("Perceptron loaded"); } catch (SerializationException e) { Debug.LogError(e.Message); } } }