Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. General Programming
  3. C#
  4. how can i use diffrence neuron count in difference layer

how can i use diffrence neuron count in difference layer

Scheduled Pinned Locked Moved C#
questioncsharpdatabasehelp
7 Posts 4 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • K Offline
    K Offline
    karayel_kara
    wrote on last edited by
    #1

    Hi, Everybody i am writing ANN code with c# i wrote a class which has folowing structure; class neuron { //public dentrit[] dent = new dentrit[nron]; //public double[,] w = new double[lay,nron];// ilk katmanda w yok dikkat public double [] dentw = new double[nron]; public double bias,hata,delta ; public double[] input = new double[nron ]; public double output ; public int[] sbaglanti = new int[nron]; public int[] sbagk = new int[nron]; public int[] obaglanti = new int[nron]; public int numara; public int dents;//dentrit sayısı public int oid,sid; ~neuron() { } } class layer { public neuron[] noron = new neuron[nron]; public layer() { for (int index = 0; index < noron.Length; index++) { noron[index] = new neuron(); } } ~layer(){} } class net { public int ban, hen; public layer[] layers = new layer[lay]; public net() { for (int index = 0; index < layers.Length; index++) { layers[index] = new layer(); } } ~net(){} } net networks; in here, i want to change neuron count of layers and so how can i do it ? can you help me ? thanks

    A H L 3 Replies Last reply
    0
    • K karayel_kara

      Hi, Everybody i am writing ANN code with c# i wrote a class which has folowing structure; class neuron { //public dentrit[] dent = new dentrit[nron]; //public double[,] w = new double[lay,nron];// ilk katmanda w yok dikkat public double [] dentw = new double[nron]; public double bias,hata,delta ; public double[] input = new double[nron ]; public double output ; public int[] sbaglanti = new int[nron]; public int[] sbagk = new int[nron]; public int[] obaglanti = new int[nron]; public int numara; public int dents;//dentrit sayısı public int oid,sid; ~neuron() { } } class layer { public neuron[] noron = new neuron[nron]; public layer() { for (int index = 0; index < noron.Length; index++) { noron[index] = new neuron(); } } ~layer(){} } class net { public int ban, hen; public layer[] layers = new layer[lay]; public net() { for (int index = 0; index < layers.Length; index++) { layers[index] = new layer(); } } ~net(){} } net networks; in here, i want to change neuron count of layers and so how can i do it ? can you help me ? thanks

      A Offline
      A Offline
      Alan Balkany
      wrote on last edited by
      #2

      Just change the value of nron.

      K 1 Reply Last reply
      0
      • A Alan Balkany

        Just change the value of nron.

        K Offline
        K Offline
        karayel_kara
        wrote on last edited by
        #3

        :) i want to difference neuron in diffrence layers it means firs layer which has 4 neurons and second layer 7 neurons ...

        A 1 Reply Last reply
        0
        • K karayel_kara

          :) i want to difference neuron in diffrence layers it means firs layer which has 4 neurons and second layer 7 neurons ...

          A Offline
          A Offline
          Alan Balkany
          wrote on last edited by
          #4

          Make a Layer constructor with an int parameter giving the Layer's length. Then in class net, pass the length you want when you make a new Layer. Take the initialization of noron out of class Layer, and allocate this array in the Layer constructor with the proper length.

          A 1 Reply Last reply
          0
          • K karayel_kara

            Hi, Everybody i am writing ANN code with c# i wrote a class which has folowing structure; class neuron { //public dentrit[] dent = new dentrit[nron]; //public double[,] w = new double[lay,nron];// ilk katmanda w yok dikkat public double [] dentw = new double[nron]; public double bias,hata,delta ; public double[] input = new double[nron ]; public double output ; public int[] sbaglanti = new int[nron]; public int[] sbagk = new int[nron]; public int[] obaglanti = new int[nron]; public int numara; public int dents;//dentrit sayısı public int oid,sid; ~neuron() { } } class layer { public neuron[] noron = new neuron[nron]; public layer() { for (int index = 0; index < noron.Length; index++) { noron[index] = new neuron(); } } ~layer(){} } class net { public int ban, hen; public layer[] layers = new layer[lay]; public net() { for (int index = 0; index < layers.Length; index++) { layers[index] = new layer(); } } ~net(){} } net networks; in here, i want to change neuron count of layers and so how can i do it ? can you help me ? thanks

            H Offline
            H Offline
            Henry Minute
            wrote on last edited by
            #5

            Firstly I hope that your knowledge of Neural Networks is greater than your knowledge of programming, otherwise I fear that this particular project is going to be beyond your capabilities. :) Still, let's get on with a little help: The first thing that I would do is to change your net class, something like this

            class net {

            public int ban, hen;
            public layer\[\] layers;
            
            public net()
            {
              layers = new layer\[lay\];
            
              for (int index = 0; index < layers.Length; index++)
              {
                layers\[index\] = new layer();
              }
            }
            
            public net(int lays)
            {
              layers = new layer\[lays\];
            
              for (int index = 0; index < layers.Length; index++)
              {
                layers\[index\] = new layer();
              }
            }
            
            ~net(){}
            

            }

            You will see that I suggest moving the instantiation of your layer[] to within the constructor. I have also added a constructor that takes an int as a parameter. With the class defined in this way: net networks = new net(); gets you a network with the standard number of layers (whatever you have set your lay member to) net networks = new net(25); gets you a network with 25 layers. For your actual question I would suggest that one method would be to add yet another constructor to the net class and one in the layer class. Firstly, layer gets the same treatment as above, for the same reason.

                public neuron\[\] noron;
            
                public layer()
                {
                    noron = new neuron\[nron\];
            
                    for (int index = 0; index < noron.Length; index++)
                    {
                        noron\[index\] = new neuron();
                    }
                }
            
                public layer(int neurons)
                {
                    noron = new neuron\[neurons\];
            
                    for (int index = 0; index < noron.Length; index++)
                    {
                        noron\[index\] = new neuron();
                    }
                }
            

            I have just listed the new constructors. In the net class the new constructor would look something like:

            public net(int lays, int\[\] neuronMap)
            {
              if (neurons.Length != lays)
              {
                  throw new ArgumentException("neurons");
              }
            
              layers = new layer\[lays\];
            
              for (int index = 0; index < layers.Length; index++)
              {
                layers\[index\] = new layer(neuronMap\[index\]);
              }
            }
            
            ~net(){}
            
            1 Reply Last reply
            0
            • A Alan Balkany

              Make a Layer constructor with an int parameter giving the Layer's length. Then in class net, pass the length you want when you make a new Layer. Take the initialization of noron out of class Layer, and allocate this array in the Layer constructor with the proper length.

              A Offline
              A Offline
              Alan Balkany
              wrote on last edited by
              #6

              You also need to make some changes to class neuron so that the arrays of weights to the previous and following layers have matching lengths.

              1 Reply Last reply
              0
              • K karayel_kara

                Hi, Everybody i am writing ANN code with c# i wrote a class which has folowing structure; class neuron { //public dentrit[] dent = new dentrit[nron]; //public double[,] w = new double[lay,nron];// ilk katmanda w yok dikkat public double [] dentw = new double[nron]; public double bias,hata,delta ; public double[] input = new double[nron ]; public double output ; public int[] sbaglanti = new int[nron]; public int[] sbagk = new int[nron]; public int[] obaglanti = new int[nron]; public int numara; public int dents;//dentrit sayısı public int oid,sid; ~neuron() { } } class layer { public neuron[] noron = new neuron[nron]; public layer() { for (int index = 0; index < noron.Length; index++) { noron[index] = new neuron(); } } ~layer(){} } class net { public int ban, hen; public layer[] layers = new layer[lay]; public net() { for (int index = 0; index < layers.Length; index++) { layers[index] = new layer(); } } ~net(){} } net networks; in here, i want to change neuron count of layers and so how can i do it ? can you help me ? thanks

                L Offline
                L Offline
                Lost User
                wrote on last edited by
                #7

                Why do you have a destructor? An empty one even. It doesn't even do anything, except slow you down.

                MSDN: Destructors (C# Programming Guide):

                Empty destructors should not be used. When a class contains a destructor, an entry is created in the Finalize queue. When the destructor is called, the garbage collector is invoked to process the queue. If the destructor is empty, this just causes a needless loss of performance.

                1 Reply Last reply
                0
                Reply
                • Reply as topic
                Log in to reply
                • Oldest to Newest
                • Newest to Oldest
                • Most Votes


                • Login

                • Don't have an account? Register

                • Login or register to search.
                • First post
                  Last post
                0
                • Categories
                • Recent
                • Tags
                • Popular
                • World
                • Users
                • Groups