Ejemplo n.º 1
0
 /// <summary>Creates an instance of the <code>ConnectionMatrix</code> class.</summary>
 /// <param name="inputSize">The size of the input of the layer.</param>
 /// <param name="outputSize">The size of the output of the layer.</param>
 /// <param name="createIO">Whether the input array and the output array of the layer are to be created.</param>
 public ConnectionMatrix(int inputSize, int outputSize, bool createIO = false)
 {
     if (createIO)
     {
         this.input      = Backbone.CreateArray <float>(inputSize);
         this.output     = Backbone.CreateArray <float>(outputSize);
         this.inputSkip  = 0;
         this.outputSkip = 0;
     }
     this.inputSize  = inputSize;
     this.outputSize = outputSize;
     this.weights    = Backbone.CreateArray <float>(inputSize, outputSize);
     Backbone.RandomizeMatrix(this.weights, inputSize, outputSize, 2.0F / (inputSize + outputSize));
     this.gradients = Backbone.CreateArray <float>(inputSize, outputSize);
     this.momentum  = Backbone.CreateArray <float>(inputSize, outputSize);
     this.siameseID = new object();
 }
Ejemplo n.º 2
0
 /// <summary>Either creates a siamese of the given <code>ConnectionMatrix</code> instance or clones it.</summary>
 /// <param name="original">The original instance to be created a siamese of or cloned.</param>
 /// <param name="siamese"><code>true</code> if a siamese is to be created, <code>false</code> if a clone is.</param>
 protected ConnectionMatrix(ConnectionMatrix original, bool siamese)
 {
     this.inputSize  = original.InputSize;
     this.outputSize = original.OutputSize;
     if (siamese)
     {
         this.weights   = original.Weights;
         this.gradients = original.Gradients;
         this.momentum  = original.Momentum;
         this.siameseID = original.SiameseID;
     }
     else
     {
         this.weights = Backbone.CreateArray <float>(original.InputSize, original.OutputSize);
         Backbone.RandomizeMatrix(this.weights, original.InputSize, original.OutputSize, 2.0F / (original.InputSize + original.OutputSize));
         this.gradients = Backbone.CreateArray <float>(original.InputSize, original.OutputSize);
         this.momentum  = Backbone.CreateArray <float>(original.InputSize, original.OutputSize);
         this.siameseID = new object();
     }
 }