本文整理汇总了C#中numl.Math.LinearAlgebra.Vector.Dot方法的典型用法代码示例。如果您正苦于以下问题:C# Vector.Dot方法的具体用法?C# Vector.Dot怎么用?C# Vector.Dot使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类numl.Math.LinearAlgebra.Vector
的用法示例。
在下文中一共展示了Vector.Dot方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Compute
/// <summary>Computes.</summary>
/// <exception cref="InvalidOperationException">Thrown when the requested operation is invalid.</exception>
/// <param name="x">The Vector to process.</param>
/// <param name="y">The Vector to process.</param>
/// <returns>A double.</returns>
public double Compute(Vector x, Vector y)
{
if (x.Length != y.Length)
throw new InvalidOperationException("Cannot compute similarity between two unequally sized Vectors!");
var xSum = x.Sum();
var ySum = y.Sum();
var xElem = (x^2).Sum() - ((xSum * xSum) / x.Length);
var yElem = (y^2).Sum() - ((ySum * ySum) / y.Length);
return (x.Dot(y) - ((xSum * ySum) / x.Length)) / System.Math.Sqrt(xElem * yElem);
}
示例2: ComputeCost
/// <summary>
/// Compute the error cost of the given Theta parameter for the training and label sets
/// </summary>
/// <param name="theta">Learning Theta parameters</param>
/// <param name="X">Training set</param>
/// <param name="y">Training labels</param>
/// <param name="lambda">Regularization constant</param>
/// <param name="regularizer">Regularization term function.</param>
/// <returns></returns>
public double ComputeCost(Vector theta, Matrix X, Vector y, double lambda, IRegularizer regularizer)
{
int m = X.Rows;
double j = 0.0;
Vector s = (X * theta).ToVector();
IFunction function = new Logistic();
s = s.Each(v => function.Compute(v));
Vector slog = s.Copy().Each(v => System.Math.Log(System.Math.Abs(1.0 - v)));
j = (-1.0 / m) * ( (y.Dot(s.Log())) + (-1.0 * ((1.0 - y).Dot(slog))) );
if (lambda != 0)
{
j = regularizer.Regularize(j, theta, m, lambda);
}
return j;
}
示例3: Compute
public double Compute(Vector x, Vector y)
{
double dot = x.Dot(y);
return dot / (System.Math.Pow(x.Norm(), 2) + System.Math.Pow(y.Norm(), 2) - dot);
}
示例4: Compute
/// <summary>
/// Computes the linear kernel function between the two input vectors.
/// </summary>
/// <param name="v1">Vector one.</param>
/// <param name="v2">Vector two.</param>
/// <returns>Similarity.</returns>
public double Compute(Vector v1, Vector v2)
{
return v1.Dot(v2);
}
示例5: Compute
/// <summary>Computes.</summary>
/// <param name="x">The Vector to process.</param>
/// <param name="y">The Vector to process.</param>
/// <returns>A double.</returns>
public double Compute(Vector x, Vector y)
{
return x.Dot(y) / (x.Norm() * y.Norm());
}
示例6: Compute
/// <summary>
/// Computes the logistic kernel function between the two input vectors.
/// </summary>
/// <param name="v1">Vector one.</param>
/// <param name="v2">Vector two.</param>
/// <returns>Similarity.</returns>
public double Compute(Vector v1, Vector v2)
{
return LogisticFunction.Compute(v1.Dot(v2));
}
示例7: Compute
/// <summary>Computes.</summary>
/// <param name="x">The Vector to process.</param>
/// <param name="y">The Vector to process.</param>
/// <returns>A double.</returns>
public double Compute(Vector x, Vector y)
{
var dot = x.Dot(y);
return dot / (Math.Pow(x.Norm(), 2) + Math.Pow(y.Norm(), 2) - dot);
}
示例8: Predict
/// <summary>
/// Create a prediction based on the learned Theta values and the supplied test item.
/// </summary>
/// <param name="y">Training record</param>
/// <returns></returns>
public override double Predict(Vector y)
{
y = this.Normalise(y);
return y.Dot(this.Theta);
}
示例9: Compute
/// <summary>
/// Computes the polynomial kernel function between the two input vectors.
/// </summary>
/// <param name="v1">Vector one.</param>
/// <param name="v2">Vector two.</param>
/// <returns>Similarity.</returns>
public double Compute(Vector v1, Vector v2)
{
return System.Math.Pow((1d + v1.Dot(v2)), Dimension);
}