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


C# Vector.Each方法代码示例

本文整理汇总了C#中numl.Math.LinearAlgebra.Vector.Each方法的典型用法代码示例。如果您正苦于以下问题:C# Vector.Each方法的具体用法?C# Vector.Each怎么用?C# Vector.Each使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在numl.Math.LinearAlgebra.Vector的用法示例。


在下文中一共展示了Vector.Each方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Compute

        /// <summary>
        /// Returns a softmax function vector from the supplied inputs.
        /// </summary>
        /// <param name="x"></param>
        /// <returns></returns>
        public Vector Compute(Vector x)
        {
            double max = x.Max();
            Vector softmax = x.Each(v => System.Math.Exp(v - max));

            double sum = softmax.Sum();

            softmax = softmax.Each(s => s / sum);

            return softmax;
        }
开发者ID:sethjuarez,项目名称:numl,代码行数:16,代码来源:Softmax.cs

示例2: Normal

 /// <summary>Compute probability according to multivariate Gaussian.</summary>
 /// <param name="x">Vector in question.</param>
 /// <param name="mu">Mean.</param>
 /// <param name="sigma">diag(covariance)</param>
 /// <returns>Probability.</returns>
 public double Normal(Vector x, Vector mu, Vector sigma)
 {
     var p = 1 / sqrt(pow(2 * System.Math.PI, mu.Length) * sigma.Prod());
     var exp = -0.5d * ((x - mu) * sigma.Each(d => 1 / d, true)).Dot(x - mu);
     var e_exp = pow(System.Math.E, exp);
     return p * e_exp;
 }
开发者ID:m-abubakar,项目名称:numl,代码行数:12,代码来源:GMM.cs

示例3: Normal

        /// <summary>
        /// Compute probability according to multivariate Gaussian
        /// </summary>
        /// <param name="x">Vector in question</param>
        /// <param name="mu">Mean</param>
        /// <param name="sigma">diag(covariance)</param>
        /// <returns>Probability</returns>
        private double Normal(Vector x, Vector mu, Vector sigma)
        {
            // 1 / (2pi)^(2/D) where D = length of sigma
            var one_over_2pi = 1 / System.Math.Pow(2 * System.Math.PI, 2 / sigma.Length);

            // 1 / sqrt(det(sigma)) where det(sigma) is the product of the diagonals

            var one_over_det_sigma = System.Math.Sqrt(sigma.Aggregate(1d, (a, i) => a *= i));

            // -.5 (x-mu).T sigma^-1 (x-mu) I have taken some liberties ;)
            var exp = -0.5d * ((x - mu) * sigma.Each(d => 1 / d, true)).Dot(x - mu);

            // e^(exp)
            var e_exp = System.Math.Pow(System.Math.E, exp);

            var result = one_over_2pi * one_over_det_sigma * e_exp;

            return result;
        }
开发者ID:budbjames,项目名称:numl,代码行数:26,代码来源:GMM.cs

示例4: Initialize

 /// <summary>
 /// Initializes the selection function.
 /// </summary>
 /// <param name="alpha">Alpha vector</param>
 /// <param name="gradient">Gradient vector.</param>
 public void Initialize(Vector alpha, Vector gradient)
 {
     alpha.Each((d) => 0, false);
     gradient.Each((d) => -1, false);
 }
开发者ID:sethjuarez,项目名称:numl,代码行数:10,代码来源:WorkingSetSelection3.cs


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