本文整理汇总了C#中numl.Math.LinearAlgebra.Vector.Insert方法的典型用法代码示例。如果您正苦于以下问题:C# Vector.Insert方法的具体用法?C# Vector.Insert怎么用?C# Vector.Insert使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类numl.Math.LinearAlgebra.Vector
的用法示例。
在下文中一共展示了Vector.Insert方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Normalise
private Vector Normalise(Vector y)
{
for (int i = 0; i < y.Length; i++)
{
y[i] = PreProcessing.FeatureNormalizer.FeatureScale(y[i], this.FeatureAverages[i], this.FeatureStandardDeviations[i]);
}
return y.Insert(0, 1.0d);
}
示例2: Predict
/// <summary>
/// Create a prediction based on the learned Theta values and the supplied test item.
/// </summary>
/// <param name="x">Training record</param>
/// <returns></returns>
public override double Predict(Vector x)
{
this.Preprocess(x);
return x.Insert(0, 1.0, false).Dot(Theta);
}
示例3: PredictRaw
/// <summary>
/// Computes the probability of the prediction being True.
/// </summary>
/// <param name="x"></param>
/// <returns></returns>
public double PredictRaw(Vector x)
{
x = IncreaseDimensions(x, this.PolynomialFeatures);
this.Preprocess(x);
return LogisticFunction.Compute(x.Insert(0, 1.0, false).Dot(Theta));
}
示例4: Convert
/// <summary>
/// Converts the experience pair into their equivalent math forms.
/// </summary>
/// <param name="state">IMDPState instance.</param>
/// <param name="nodes">List of nodes added to the result set.</param>
/// <param name="states">Matrix to store contained successor state vectors.</param>
/// <param name="actions">Vector to store the contained action values.</param>
/// <param name="statesP">Matrix to store all contained successor transition state vectors.</param>
/// <param name="rewards">Vector to store all contained reward values.</param>
/// <returns>HashSet<string></returns>
private static void Convert(this IMDPState state, ref List<string> nodes, ref Matrix states, ref Vector actions, ref Matrix statesP, ref Vector rewards)
{
if (state != null)
{
foreach (IMDPSuccessor successor in state.GetSuccessors())
{
if (state.Features.Length != states.Cols)
states = Matrix.Reshape(states, states.Rows, state.Features.Length);
if (state.Features.Length != statesP.Cols)
statesP = Matrix.Reshape(statesP, statesP.Rows, ((IMDPState) successor.State).Features.Length);
string id = $"{state.Id}:{successor.State.Id}";
if (!nodes.Contains(id))
{
states = states.Insert(state.ToVector(), states.Rows - 1, VectorType.Row);
actions = actions.Insert(actions.Length - 1, successor.Action.Id);
statesP = statesP.Insert(((IMDPState) successor.State).ToVector(), statesP.Rows - 1, VectorType.Row);
rewards = rewards.Insert(rewards.Length - 1, successor.Reward);
nodes.Add(id);
}
if (!successor.State.IsTerminal)
{
var successorState = ((IMDPState) successor.State);
if (successorState.Id != state.Id)
successorState.Convert(ref nodes, ref states, ref actions, ref statesP, ref rewards);
}
}
}
}