本文整理汇总了C#中Dataset.AddPair方法的典型用法代码示例。如果您正苦于以下问题:C# Dataset.AddPair方法的具体用法?C# Dataset.AddPair怎么用?C# Dataset.AddPair使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Dataset
的用法示例。
在下文中一共展示了Dataset.AddPair方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Create
public static Dataset Create()
{
Dataset result = new Dataset();
Bitmap bmp = new Bitmap(width, height);
StringFormat stringFormat = new StringFormat();
stringFormat.Alignment = StringAlignment.Center;
stringFormat.LineAlignment = StringAlignment.Center;
float size = 8;
Rectangle rect = new Rectangle(0, 0, width, height);
using (Graphics g = Graphics.FromImage(bmp))
{
g.TextRenderingHint = TextRenderingHint.ClearTypeGridFit;
for (int x = 0; x < 100; ++x)
{
// var fonts = fontsToTrain.Shuffle().ToList();
// foreach (var f in fonts)
{
var ai = Enumerable.Range(0, alphabet.Length).Shuffle().ToList();
// for (int i = 0; i < alphabet.Length; ++i)
foreach (var i in ai)
{
var f = fontsToTrain[Tools.rnd.Next(fontsToTrain.Length)];
size = 9.0f + (float)Tools.rnd.NextDouble() * 4.0f;
using (Font font = new Font(f, size))
{
var a = alphabet[i];
g.Clear(Color.Black);
g.TextRenderingHint = TextRenderingHint.AntiAlias;
g.CompositingQuality = System.Drawing.Drawing2D.CompositingQuality.HighQuality;
g.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.HighQuality;
g.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.HighQualityBicubic;
g.TranslateTransform(width / 2, height / 2);
g.RotateTransform(((float)Tools.rnd.NextDouble()-0.5f) * 45);
g.TranslateTransform(-width / 2, -height / 2);
var dx = ((float)Tools.rnd.NextDouble() - 0.5f) * 2.0f;
var dy = ((float)Tools.rnd.NextDouble() - 0.5f) * 2.0f;
g.TranslateTransform(dx, dy);
g.DrawString(a, font, Brushes.White, rect, stringFormat);
g.ResetTransform();
var inp = Tools.bmp_to_float(bmp);
var outp = new float[alphabet.Length];
outp[i] = 1.0f;
result.AddPair(inp, outp);
}
}
}
}
}
result.VisualizeInput = visualizeInput;
result.VisualizeOutput = visualizeOutput;
return result;
}