public IEnumerable <Prediction> PredictTopN(RawDrawing drawing, int predictionsCount, double minActivation) { if (Evaluator == null) { return(null); } var normDrawing = dataProcessor.Normalize(drawing); var img = rasterizer.Rasterize(normDrawing, TrainSettings.InputImgSizePx, TrainSettings.PenThicknessPerc / 100f, true, false); var input = inputConvertor.ImageToVector(img); return(Evaluator.PredictTopN(input, predictionsCount, minActivation)); }
public Matrix <double> CreateInputsMatrix(IEnumerable <RawDrawing> rawDrawings, Rasterizer rasterizer, bool normalize) { Contract.Requires(rawDrawings.Count() > 0); var inputVectors = new List <Vector <double> >(); using (var img = new Bitmap(rasterizer.ImageSize, rasterizer.ImageSize, PixelFormat.Format24bppRgb)) { int cols = img.Width * img.Height; foreach (var drawing in rawDrawings) { RawDrawing rd = normalize ? dataProcessor.Normalize(drawing) : drawing; rasterizer.Rasterize(img, rd); inputVectors.Add(ImageToVector(img)); } } return(DenseMatrix.OfRowVectors(inputVectors)); }