当前位置: 首页>>代码示例>>C#>>正文


C# Vector.Dot方法代码示例

本文整理汇总了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);
        }
开发者ID:m-abubakar,项目名称:numl,代码行数:18,代码来源:PearsonCorrelation.cs

示例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;
        }
开发者ID:m-abubakar,项目名称:numl,代码行数:31,代码来源:LogisticCostFunction.cs

示例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);
 }
开发者ID:budbjames,项目名称:numl,代码行数:5,代码来源:TanimotoCoefficient.cs

示例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);
 }
开发者ID:sethjuarez,项目名称:numl,代码行数:10,代码来源:LinearKernel.cs

示例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());
 }
开发者ID:m-abubakar,项目名称:numl,代码行数:8,代码来源:CosineSimilarity.cs

示例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));
 }
开发者ID:sethjuarez,项目名称:numl,代码行数:10,代码来源:LogisticKernel.cs

示例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);
 }
开发者ID:ChewyMoon,项目名称:Cupcake,代码行数:9,代码来源:TanimotoCoefficient.cs

示例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);
        }
开发者ID:ChewyMoon,项目名称:Cupcake,代码行数:11,代码来源:LinearRegressionModel.cs

示例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);
 }
开发者ID:sethjuarez,项目名称:numl,代码行数:10,代码来源:PolyKernel.cs


注:本文中的numl.Math.LinearAlgebra.Vector.Dot方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。