本文整理汇总了C#中DoubleVector.Fill方法的典型用法代码示例。如果您正苦于以下问题:C# DoubleVector.Fill方法的具体用法?C# DoubleVector.Fill怎么用?C# DoubleVector.Fill使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DoubleVector
的用法示例。
在下文中一共展示了DoubleVector.Fill方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetPatternList
private List<Pattern> GetPatternList(List<Bitmap> segments, List<string> solutions)
{
try
{
List<Pattern> list = new List<Pattern>();
// If there are an unequal number of segments and solutions, then we probably segmented incorrectly.
// We cannot tell the segmenter to segment to the same number of letters for an image we know the answer to,
// because then when we try to segment an image we don't have the solution to we won't know the answer.
for (int i = 0; i < Math.Min(segments.Count, solutions.Count); i++)
{
DoubleVector inputs = new DoubleVector(solver.ExpectedWidth * solver.ExpectedHeight);
DoubleVector outputs = new DoubleVector(solver.CharacterSet.Count);
// Create the input pattern
for (int x = 0; x < solver.ExpectedWidth; x++)
{
for (int y = 0; y < solver.ExpectedHeight; y++)
{
Color c = segments[i].GetPixel(x, y);
inputs[x * solver.ExpectedHeight + y] = 1.0 - (c.R * c.G * c.B) / (255.0 * 255.0 * 255.0);
}
}
// Create the output pattern. Each element corresponds to one character in the set of all possible characters.
// Use numbers close to 0 and 1, not the actual numbers to help in training.
outputs.Fill(0.01);
outputs[solver.CharacterSet.IndexOf(solutions[i])] = 0.99;
list.Add(new Pattern() { Inputs = inputs, Outputs = outputs });
}
return list;
}
catch (Exception ex)
{
throw new PatternGenerationException("Error trying to create a list of patterns from a list of bitmaps and their corresponding solutions.", ex);
}
}