當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。