private static Convolution2D Convolute(Convolution2D conv, ToVectorInstructions instr) { Convolution2D retVal = conv; if (retVal.Width != retVal.Height) { int max = Math.Max(retVal.Width, retVal.Height); retVal = Convolutions.ExtendBorders(retVal, max, max); // make it square } if (instr.ShouldNormalize) { retVal = Convolutions.Normalize(retVal); } if (instr.Convolution != null) { retVal = Convolutions.Convolute(retVal, instr.Convolution); } retVal = Convolutions.MaxPool(retVal, instr.ToSize, instr.ToSize); retVal = Convolutions.Abs(retVal); return(retVal); }