本文整理汇总了C#中Variable.SetTo方法的典型用法代码示例。如果您正苦于以下问题:C# Variable.SetTo方法的具体用法?C# Variable.SetTo怎么用?C# Variable.SetTo使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Variable
的用法示例。
在下文中一共展示了Variable.SetTo方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: LDAPredictionModel
/// <summary>
/// Constructs an LDA model
/// </summary>
/// <param name="sizeVocab">Size of vocabulary</param>
/// <param name="numTopics">Number of topics</param>
public LDAPredictionModel(int sizeVocab, int numTopics)
{
SizeVocab = sizeVocab;
NumTopics = numTopics;
PredictionSparsity = Sparsity.Sparse;
//---------------------------------------------
// The model
//---------------------------------------------
Range W = new Range(SizeVocab).Named("W");
Range T = new Range(NumTopics).Named("T");
ThetaPrior = Variable.New<Dirichlet>().Named("ThetaPrior");
PhiPrior = Variable.Array<Dirichlet>(T).Named("PhiPrior").Attrib(new ValueRange(W));
Theta = Variable.New<Vector>().Named("Theta");
Phi = Variable.Array<Vector>(T).Named("Phi");
Theta = Variable.Random<Vector, Dirichlet>(ThetaPrior);
Phi[T] = Variable.Random<Vector, Dirichlet>(PhiPrior[T]);
Word = Variable.New<int>().Named("Word");
Word.SetSparsity(PredictionSparsity);
var topic = Variable.Discrete(Theta).Attrib(new ValueRange(T)).Named("topic");
using (Variable.Switch(topic))
Word.SetTo(Variable.Discrete(Phi[topic]));
Engine = new InferenceEngine(new VariationalMessagePassing());
Engine.Compiler.ShowWarnings = false;
}
示例2: CreateModel
public override void CreateModel()
{
base.CreateModel();
Variable<int> componentIndex = Variable.Discrete(MixingCoefficients);
TomorrowsTime = Variable.New<double>();
using (Variable.Switch(componentIndex))
{
TomorrowsTime.SetTo(
Variable.GaussianFromMeanAndPrecision(
AverageTime[componentIndex],
TrafficNoise[componentIndex]));
}
}