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


C# Vector.SetToProduct方法代码示例

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


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

示例1: EvaluateX

        /// <summary>
        /// Evaluates the kernel for a single vector (which is used for both slots)
        /// </summary>
        /// <param name="x">Vector</param>
        /// <param name="xDeriv">Derivative of the kernel value with respect to x</param>
        /// <param name="logThetaDeriv">Derivative of the kernel value with respect to the log hyper-parameters</param>
        /// <returns></returns>
        public override double EvaluateX(Vector x, ref Vector xDeriv, ref Vector logThetaDeriv)
        {
            int numInputs = variances.Count;
			Vector dvec = Vector.Zero(numInputs);
            dvec.SetToProduct(variances, x);
            double result = x.Inner(dvec);

            if (((object)logThetaDeriv) != null)
            {
                logThetaDeriv.SetToProduct(x, dvec);
            }

            if (((object)xDeriv) != null)
            {
                xDeriv.SetToProduct(dvec, 2.0);
            }
            return result;
        }
开发者ID:xornand,项目名称:Infer.Net,代码行数:25,代码来源:LinearKernel.cs

示例2: EvaluateX1X2

        /// <summary>
        /// Evaluates the kernel for a pair of vectors
        /// </summary>
        /// <param name="x1">First vector</param>
        /// <param name="x2">Second vector</param>
        /// <param name="x1Deriv">Derivative of the kernel value with respect to x1 input vector</param>
        /// <param name="logThetaDeriv">Derivative of the kernel value with respect to the log hyper-parameters</param>
        /// <returns></returns>
        public override double EvaluateX1X2(Vector x1, Vector x2, ref Vector x1Deriv, ref Vector logThetaDeriv)
        {
            if (Object.ReferenceEquals(x1,x2))
            {
                return EvaluateX(x1, ref x1Deriv, ref logThetaDeriv);
            }
            else
            {
                int numInputs = variances.Count;
				Vector dvec = Vector.Zero(numInputs);
                dvec.SetToProduct(variances, x2);
                double result = x1.Inner(dvec);

                if (((object)logThetaDeriv) != null)
                {
                    logThetaDeriv.SetToProduct(x1, dvec);
                }

                if (((object)x1Deriv) !=  null)
                {
                    x1Deriv.SetTo(dvec);
                }
                return result;
            }
        }
开发者ID:xornand,项目名称:Infer.Net,代码行数:33,代码来源:LinearKernel.cs

示例3: EvaluateX1X2

		/// <summary>
		/// Evaluates the kernel for a pair of vectors
		/// </summary>
		/// <param name="x1">First vector</param>
		/// <param name="x2">Second vector</param>
		/// <param name="x1Deriv">Derivative of the kernel value with respect to x1 input vector</param>
		/// <param name="logThetaDeriv">Derivative of the kernel value with respect to the log hyper-parameters</param>
		/// <returns></returns>
		public override double EvaluateX1X2(Vector x1, Vector x2, ref Vector x1Deriv, ref Vector logThetaDeriv)
		{
			if (object.ReferenceEquals(x1, x2)) {
				return EvaluateX(x1, ref x1Deriv, ref logThetaDeriv);
			} else {
				Vector dvec = Vector.Zero(x1.Count);
				dvec.SetToDifference(x1, x2);
				double d = lenMult * dvec.Inner(dvec);
				double de = Math.Exp(d);
				double result = signalVar * de;
				if (((object)logThetaDeriv) != null) {
					logThetaDeriv[0] = -2.0 * result * d;
					logThetaDeriv[1] = 2.0 * signalVar * de;
				}
				if (((object)x1Deriv) != null) {
					x1Deriv.SetToProduct(dvec, result * 2.0 * lenMult);
				}
				return result;
			}
		}
开发者ID:xornand,项目名称:Infer.Net,代码行数:28,代码来源:SquaredExponential.cs

示例4: LogAverageFactor

		/// <summary>
		/// Evidence message for EP
		/// </summary>
		/// <param name="prob">Constant value for 'prob'.</param>
		/// <param name="mean">Constant value for 'mean'.</param>
		/// <param name="totalCount">Constant value for 'totalCount'.</param>
		/// <returns>Logarithm of the factor's average value across the given argument distributions</returns>
		/// <remarks><para>
		/// The formula for the result is <c>log(factor(prob,mean,totalCount))</c>.
		/// </para></remarks>
		public static double LogAverageFactor(Vector prob, Vector mean, double totalCount)
		{
			var temp = mean.Clone();
			mean.SetToProduct(mean, totalCount);
			var d = new Dirichlet(temp);
			return d.GetLogProb(prob);
		}
开发者ID:xornand,项目名称:Infer.Net,代码行数:17,代码来源:DirichletOp.cs

示例5: EvaluateX1X2

        /// <summary>
        /// Evaluates the kernel for a pair of vectors
        /// </summary>
        /// <param name="x1">First vector</param>
        /// <param name="x2">Second vector</param>
        /// <param name="x1Deriv">Derivative of the kernel value with respect to x1 input vector</param>
        /// <param name="logThetaDeriv">Derivative of the kernel value with respect to the log hyper-parameters</param>
        /// <returns></returns>
        public override double EvaluateX1X2(Vector x1, Vector x2, ref Vector x1Deriv, ref Vector logThetaDeriv)
        {
            if (Object.ReferenceEquals(x1,x2))
            {
                return EvaluateX(x1, ref x1Deriv, ref logThetaDeriv);
            }
            else
            {
                int numInputs = invLength.Count;
				Vector dvec = Vector.Zero(numInputs);
                dvec.SetToDifference(x1, x2);

                // Factor in the inverse length
                dvec.SetToProduct(dvec, invLength);

                double d = -0.5 * dvec.Inner(dvec);
                double de = Math.Exp(d);

                double result = signalVar * de;

                if (((object)logThetaDeriv) != null)
                {
                    for (int i = 0; i < numInputs; i++)
                    {
                        logThetaDeriv[i] = result * dvec[i] * dvec[i];
                    }
                    logThetaDeriv[numInputs] = 2.0 * signalVar * de;
                }

                if (((object)x1Deriv) !=  null)
                {
                    x1Deriv.SetToProduct(dvec, -result);
                    x1Deriv.SetToProduct(x1Deriv, invLength);
                }
                return result;
            }
        }
开发者ID:xornand,项目名称:Infer.Net,代码行数:45,代码来源:ARD.cs

示例6: AverageColor

		public static Vector AverageColor(Bitmap bitmap)
		{
			Vector sum = new Vector(2);
			for (int x = 0; x < bitmap.Width; x++) {
				for (int y = 0; y < bitmap.Height; y++) {
					Color pixel = bitmap.GetPixel(x, y);
					// we encode the Hue angle as a 2D vector, scaled by saturation and brightness.
					double hue = pixel.GetHue()/360;
					double saturation = pixel.GetSaturation();
					double brightness = pixel.GetBrightness();
					double vx = brightness*saturation*Math.Cos(hue*2*Math.PI);
					double vy = brightness*saturation*Math.Sin(hue*2*Math.PI);
					sum[0] += vx;
					sum[1] += vy;
					//sum[1] += pixel.GetSaturation();
					//sum[2] += pixel.GetBrightness();
				}
			}
			sum.SetToProduct(sum, 1.0 / ((double)bitmap.Width * bitmap.Height));
			return sum;
		}
开发者ID:xornand,项目名称:Infer.Net,代码行数:21,代码来源:Program.cs


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