Ejemplo n.º 1
0
 /// <summary>Creates an instance of the <code>ConvolutionalNN</code> class.</summary>
 /// <param name="firstPart">The first part of the convolutional neural network.</param>
 /// <param name="fnn">The second part of the convolutional neural network.</param>
 /// <param name="createIO">Whether the input image and the output array of the network are to be created.</param>
 public ConvolutionalNN(PurelyConvolutionalNN firstPart, FeedForwardNN fnn, bool createIO = true)
 {
     this.firstPart  = firstPart;
     this.i2a        = new ImageToArray(firstPart.OutputDepth, firstPart.OutputWidth, firstPart.OutputHeight, false);
     this.fnn        = fnn;
     this.errorArray = Backbone.CreateArray <float>(firstPart.OutputDepth * firstPart.OutputWidth * firstPart.OutputHeight);
     this.errorImage = new Image(this.firstPart.OutputDepth, this.firstPart.OutputWidth, this.firstPart.OutputHeight);
     if (createIO)
     {
         this.SetInputGetOutput(new Image(firstPart.InputDepth, firstPart.InputWidth, firstPart.InputHeight));
     }
     this.siameseID = new object();
 }
Ejemplo n.º 2
0
 /// <summary>Creates an instance of the <code>DeConvolutionalNN</code> class.</summary>
 /// <param name="firstPart">First part of the network.</param>
 /// <param name="cnn">Second part of the network.</param>
 /// <param name="createIO">Whether the input array and the output image of the netwok are to be created.</param>
 public DeConvolutionalNN(FeedForwardNN firstPart, PurelyConvolutionalNN cnn, bool createIO = true)
 {
     this.firstPart       = firstPart;
     this.a2i             = new ArrayToImage(cnn.InputDepth, cnn.InputWidth, cnn.InputHeight, false);
     this.cnn             = cnn;
     this.errorArray      = Backbone.CreateArray <float>(cnn.InputDepth * cnn.InputWidth * cnn.InputHeight);
     this.errorImage      = new Image(cnn.InputDepth, cnn.InputWidth, cnn.InputHeight);
     this.layersConnected = false;
     if (createIO)
     {
         this.SetInputGetOutput(Backbone.CreateArray <float>(firstPart.InputSize));
     }
     this.siameseID = new object();
 }
Ejemplo n.º 3
0
        /// <summary>Either creates a siamese of the given <code>PurelyConvolutionalNN</code> class 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 PurelyConvolutionalNN(PurelyConvolutionalNN original, bool siamese) : base(original, siamese)
        {
            int maxDepth  = original.Layers.First().InputDepth;
            int maxWidth  = original.Layers.First().InputWidth;
            int maxHeight = original.Layers.First().InputHeight;

            foreach (IImagesLayer layer in original.Layers)
            {
                maxDepth  = Math.Max(maxDepth, layer.OutputDepth);
                maxWidth  = Math.Max(maxWidth, layer.OutputWidth);
                maxHeight = Math.Max(maxHeight, layer.OutputHeight);
            }
            this.error1          = new Image(maxDepth, maxWidth, maxHeight);
            this.error2          = new Image(maxDepth, maxWidth, maxHeight);
            this.layersConnected = false;
        }
Ejemplo n.º 4
0
 /// <summary>Either creates a siamese of the given <code>ConvolutionalNN</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> otherwise.</param>
 protected ConvolutionalNN(ConvolutionalNN original, bool siamese)
 {
     this.errorArray      = Backbone.CreateArray <float>(firstPart.OutputDepth * firstPart.OutputWidth * firstPart.OutputHeight);
     this.errorImage      = new Image(this.firstPart.OutputDepth, this.firstPart.OutputWidth, this.firstPart.OutputHeight);
     this.layersConnected = false;
     if (siamese)
     {
         this.firstPart = (PurelyConvolutionalNN)original.CreateSiamese();
         this.i2a       = (ImageToArray)original.i2a.CreateSiamese();
         this.fnn       = (FeedForwardNN)original.fnn.CreateSiamese();
         this.siameseID = original.SiameseID;
     }
     else
     {
         this.firstPart = (PurelyConvolutionalNN)original.firstPart.Clone();
         this.i2a       = (ImageToArray)original.i2a.Clone();
         this.fnn       = (FeedForwardNN)original.fnn.Clone();
         this.siameseID = new object();
     }
 }
Ejemplo n.º 5
0
 /// <summary>Either creates a siamese or clones the given <code>DeConvolutionalNN</code> instance.</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 DeConvolutionalNN(DeConvolutionalNN original, bool siamese)
 {
     this.errorArray      = Backbone.CreateArray <float>(original.cnn.InputDepth * original.cnn.InputWidth * original.cnn.InputHeight);
     this.errorImage      = new Image(original.cnn.InputDepth, original.cnn.InputWidth, original.cnn.InputHeight);
     this.layersConnected = false;
     if (siamese)
     {
         this.firstPart = (FeedForwardNN)original.firstPart.CreateSiamese();
         this.a2i       = (ArrayToImage)original.a2i.CreateSiamese();
         this.cnn       = (PurelyConvolutionalNN)original.cnn.CreateSiamese();
         this.siameseID = original.SiameseID;
     }
     else
     {
         this.firstPart = (FeedForwardNN)original.firstPart.Clone();
         this.a2i       = (ArrayToImage)original.a2i.Clone();
         this.cnn       = (PurelyConvolutionalNN)original.cnn.Clone();
         this.siameseID = new object();
     }
 }