public void DisplayConnections(int neuronIndex, int currentLayer, UINeuralNetLayerPanel nextLayer, bool biasLayer)
    {
        Image dummyWeight = Weights[0];

        dummyWeight.gameObject.SetActive(true);
        for (int i = Weights.Count; i < net.GetNeuronsInLayer(currentLayer + 1); i++)
        {
            if (biasLayer && i == net.GetNeuronsInLayer(currentLayer + 1) - 1)
            {
            }
            else
            {
                Image newWeight = Instantiate(dummyWeight);
                newWeight.transform.SetParent(this.transform, false);
                Weights.Add(newWeight);
            }
        }

        for (int i = this.Weights.Count - 1; i >= net.GetNeuronsInLayer(currentLayer + 1); i++)
        {
            Image toBeDestroyed = Weights[i];
            Weights.RemoveAt(i);
            Destroy(toBeDestroyed);
        }

        for (int i = 0; i < Weights.Count; i++)
        {
            float[][][] weights = net.GetWeightsMatrix();
            PositionConnection(Weights[i], nextLayer.Nodes[i], neuronIndex, i, weights[currentLayer]);
        }
    }
Example #2
0
    public void Display(NeuralNetwork net)
    {
        UINeuralNetLayerPanel dummyLayer = Layers[0];

        for (int i = Layers.Count; i < net.GetLayers().Length; i++)
        {
            UINeuralNetLayerPanel newPanel = Instantiate(dummyLayer);
            newPanel.transform.SetParent(this.transform, false);
            Layers.Add(newPanel);
        }

        for (int i = this.Layers.Count - 1; i >= net.GetLayers().Length; i++)
        {
            UINeuralNetLayerPanel toBeDestroyed = Layers[i];
            Layers.RemoveAt(i);
            Destroy(toBeDestroyed);
        }

        for (int i = 0; i < this.Layers.Count - 1; i++)
        {
            this.Layers[i].SetNeuralNet(net);
            int[] layers = net.GetLayers();
            this.Layers[i].Display(i, true);
        }

        this.Layers[Layers.Count - 1].SetNeuralNet(net);
        this.Layers[Layers.Count - 1].Display(net.GetLayers().Length - 1, false);

        StartCoroutine(DrawConnections(net));
    }
Example #3
0
 public void DisplayConnections(int currentLayer, UINeuralNetLayerPanel nextLayer, bool biasLayer)
 {
     for (int i = 0; i < Nodes.Count; i++)
     {
         Nodes[i].SetNeuralNet(net);
         Nodes[i].DisplayConnections(i, currentLayer, nextLayer, biasLayer);
     }
 }