本文整理汇总了C#中MarkovMultivariateFunction.Deoptimize方法的典型用法代码示例。如果您正苦于以下问题:C# MarkovMultivariateFunction.Deoptimize方法的具体用法?C# MarkovMultivariateFunction.Deoptimize怎么用?C# MarkovMultivariateFunction.Deoptimize使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MarkovMultivariateFunction
的用法示例。
在下文中一共展示了MarkovMultivariateFunction.Deoptimize方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: LogForwardGesturesPriorsDeoptimizedTest
public void LogForwardGesturesPriorsDeoptimizedTest()
{
int[] labels;
double[][][] words;
var classifier = IndependentMarkovFunctionTest.CreateModel4(out words, out labels, true);
var deopFun = new MarkovMultivariateFunction(classifier);
deopFun.Deoptimize();
var target1 = new HiddenConditionalRandomField<double[]>(deopFun);
var function = new MarkovMultivariateFunction(classifier);
var target2 = new HiddenConditionalRandomField<double[]>(function);
foreach (var word in words)
{
for (int c = 0; c < 3; c++)
{
for (int y = 0; y < 3; y++)
{
var actual = Accord.Statistics.Models.Fields.ForwardBackwardAlgorithm
.LogForward(target1.Function.Factors[c], word, y);
var expected = Accord.Statistics.Models.Fields.ForwardBackwardAlgorithm
.LogForward(target2.Function.Factors[c], word, y);
for (int i = 0; i < actual.GetLength(0); i++)
{
for (int j = 0; j < actual.GetLength(1); j++)
{
double a = actual[i, j];
double e = expected[i, j];
Assert.IsTrue(e.IsRelativelyEqual(a, 0.1));
}
}
}
}
}
}
示例2: ComputeDeoptimizeTest4
public void ComputeDeoptimizeTest4()
{
int[] labels;
double[][][] words;
var model = CreateModel4(out words, out labels, false);
var target = new MarkovMultivariateFunction(model);
#pragma warning disable 0618
target.Deoptimize();
#pragma warning restore 0618
var hcrf = new HiddenConditionalRandomField<double[]>(target);
Assert.AreEqual(3, model.Priors.Length);
Assert.AreEqual(1 / 3.0, model.Priors[0]);
Assert.AreEqual(1 / 3.0, model.Priors[1]);
Assert.AreEqual(1 / 3.0, model.Priors[2]);
check4(words, model, target, hcrf);
}
示例3: GradientDeoptimizeTest3
public void GradientDeoptimizeTest3()
{
double[][][] sequences2;
int[] labels2;
var hmm = CreateModel3(out sequences2, out labels2);
var function = new MarkovMultivariateFunction(hmm);
#pragma warning disable 0618
function.Deoptimize();
#pragma warning restore 0618
var model = new HiddenConditionalRandomField<double[]>(function);
var target = new ForwardBackwardGradient<double[]>(model);
target.Regularization = 2;
var inputs = sequences2;
var outputs = labels2;
FiniteDifferences diff = new FiniteDifferences(function.Weights.Length);
diff.Function = parameters => func(model, parameters, inputs, outputs, target.Regularization);
double[] expected = diff.Compute(function.Weights);
double[] actual = target.Gradient(function.Weights, inputs, outputs);
for (int i = 0; i < actual.Length; i++)
{
double e = expected[i];
double a = actual[i];
Assert.AreEqual(e, a, 1e-3);
Assert.IsFalse(double.IsNaN(actual[i]));
Assert.IsFalse(double.IsNaN(expected[i]));
}
}
示例4: ComputeDeoptimizeTest3
public void ComputeDeoptimizeTest3()
{
double[][][] sequences;
int[] labels;
var model = CreateModel3(out sequences, out labels);
var target = new MarkovMultivariateFunction(model);
#pragma warning disable 0618
target.Deoptimize();
#pragma warning restore 0618
var hcrf = new HiddenConditionalRandomField<double[]>(target);
Assert.AreEqual(2, model.Priors.Length);
Assert.AreEqual(1 / 2.0, model.Priors[0]);
Assert.AreEqual(1 / 2.0, model.Priors[1]);
check4(sequences, model, target, hcrf);
}