Exemple #1
0
        private MyAbstractWeightLayer BuildNetworkLayerMirrorNeuron(XmlNode layerItem)
        {
            MyNeuronLayer originalLayer = null;

            bool layerMissing = true;

            // Parse
            foreach (XmlAttribute layerAttribute in layerItem.Attributes)
            {
                switch (layerAttribute.Name)
                {
                case "original":
                    originalLayer = GetLayerById <MyNeuronLayer>(layerAttribute.Value);
                    layerMissing  = false;
                    break;

                default:
                    throw new MyXMLBuilderException("Unknown attribute: " + layerAttribute.Name);
                }
            }

            // Validate values
            if (layerMissing)
            {
                throw new MyXMLBuilderException("Missing original layer id");
            }

            // Success!
            MyAbstractWeightLayer layer = new MyMirrorNeuronLayer(m_network, originalLayer);

            m_network.AddLayer(layer);
            return(layer);
        }
Exemple #2
0
        private MyAbstractWeightLayer BuildNetworkLayerNeuron(XmlNode layerItem)
        {
            uint nbNeurons = 0;

            bool nbNeuronsMissing = true;

            // Parse
            foreach (XmlAttribute layerAttribute in layerItem.Attributes)
            {
                switch (layerAttribute.Name)
                {
                case "nbneurons":
                    nbNeurons        = uint.Parse(layerAttribute.Value);
                    nbNeuronsMissing = false;
                    break;

                default:
                    throw new MyXMLBuilderException("Unknown attribute: " + layerAttribute.Name);
                }
            }

            // Validate values
            if (nbNeuronsMissing)
            {
                throw new MyXMLBuilderException("Missing nbNeurons parameter");
            }

            if (nbNeurons == 0)
            {
                throw new MyXMLBuilderException("Must have at least 1 neuron");
            }

            // Success!
            float[] initialWeight = null;
            float[] initialBias   = null;
            if (m_weightLoader != null)
            {
                initialWeight = m_weightLoader.NeuronWeight[(int)m_neuronLayerCount];
                initialBias   = m_weightLoader.NeuronBias[(int)m_neuronLayerCount];
            }
            MyAbstractWeightLayer layer = new MyNeuronLayer(m_network, nbNeurons, initialWeight, initialBias);

            m_network.AddLayer(layer);
            m_neuronLayerCount++;
            return(layer);
        }
Exemple #3
0
 public MyRBMAgent(MyAbstractFeedForwardNode network, int nGPU, MyMemoryBlock <float> labelInput, uint learningDuration)
     : base(network)
 {
     layers = new List <MyAbstractFBLayer>();
     foreach (MyAbstractFBLayer l in network.Layers)
     {
         MyNeuronLayer nl = l as MyNeuronLayer;
         if (nl != null)
         {
             layers.Add(nl);
         }
         MyNeuronCopyLayer ncl = l as MyNeuronCopyLayer;
         if (ncl != null)
         {
             layers.Add(ncl);
         }
     }
     totalSteps = (int)learningDuration * (layers.Count - 1);
 }