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


C# Matrix.InitNormal方法代码示例

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


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

示例1: InitModel

		///
		protected virtual void InitModel()
		{
			user_factors = new Matrix<float>(MaxUserID + 1, NumFactors);
			item_factors = new Matrix<float>(MaxItemID + 1, NumFactors);

			user_factors.InitNormal(InitMean, InitStdDev);
			item_factors.InitNormal(InitMean, InitStdDev);
		}
开发者ID:WisonHuang,项目名称:MyMediaLite,代码行数:9,代码来源:MF.cs

示例2: InitModel

		///
		protected virtual void InitModel()
		{
			item_weights = new Matrix<float>(MaxItemID + 1, MaxItemID + 1);
			item_weights.InitNormal(InitMean, InitStdDev);

			// set diagonal elements to 0
			for(int i = 0; i <= MaxItemID; i++)
			{
				item_weights[i, i] = 0;
			}
		}
开发者ID:WisonHuang,项目名称:MyMediaLite,代码行数:12,代码来源:SLIM.cs

示例3: InitModel

		///
		protected internal override void InitModel()
		{
			base.InitModel();

			x = new Matrix<float>(item_attributes.NumberOfColumns, NumFactors);
			x.InitNormal(InitMean, InitStdDev);
			q = new Matrix<float>(MaxItemID + 1, NumFactors);
			q.InitNormal(InitMean, InitStdDev);

			// set factors to zero for items without training examples
			for (int i = 0; i < ratings.CountByItem.Count; i++)
				if (ratings.CountByItem[i] == 0)
					q.SetRowToOneValue(i, 0);
		}
开发者ID:WisonHuang,项目名称:MyMediaLite,代码行数:15,代码来源:GSVDPlusPlus.cs

示例4: InitModel

        ///
        protected override void InitModel()
        {
            base.InitModel ();

            user_factors = null;
            item_factors = null;
            p = new Matrix<float> (MaxUserID + 1, NumFactors);
            p.InitNormal (InitMean, InitStdDev);
            y = new Matrix<float> (MaxItemID + 1, NumFactors);
            y.InitNormal (InitMean, InitStdDev);
            x = new Matrix<float> (item_attributes.NumberOfColumns, NumFactors);
            x.InitNormal (InitMean, InitStdDev);
            q = new Matrix<float> (MaxItemID + 1, NumFactors);
            q.InitNormal (InitMean, InitStdDev);

            int num_attributes = item_attributes.NumberOfColumns;

            x_reg = new float[num_attributes];
            for (int attribute_id = 0; attribute_id < num_attributes; attribute_id++)
                x_reg [attribute_id] = FrequencyRegularization? (RegX / (float)(1 + Math.Exp(-0.005*item_attributes.NumEntriesByColumn (attribute_id)))) : RegX;

            y_reg = new float[MaxItemID + 1];
            for (int item_id = 0; item_id <= MaxItemID; item_id++) {
                var feedback_count_by_item = Feedback.ItemMatrix [item_id];
                if (feedback_count_by_item.Count > 0)
                    y_reg [item_id] = FrequencyRegularization ? (float)(RegY / Math.Sqrt (feedback_count_by_item.Count)) : RegY;
                else
                    y_reg [item_id] = 0;
            }

            Console.Write("Learning attributes...");
            BPRLinear learnAttr = new BPRLinear();
            learnAttr.Feedback = Feedback;
            learnAttr.ItemAttributes = item_attributes;
            learnAttr.NumIter = NumIter;//10;
            learnAttr.LearnRate = LearnRate;//0.05f;
            learnAttr.Regularization = 0.015f;//0.001f;
            learnAttr.Train();
            item_attribute_weight_by_user = learnAttr.ItemAttributeWeights;
            learnAttr = null;
            Console.WriteLine ("Done");
        }
开发者ID:wendelad,项目名称:RecSys,代码行数:43,代码来源:BPR_GSVDPlusPlus.cs

示例5: InitModel

        ///
        protected internal override void InitModel()
        {
            base.InitModel();

            p = new Matrix<float>(MaxUserID + 1, NumFactors);
            p.InitNormal(InitMean, InitStdDev);
            y = new Matrix<float>(MaxItemID + 1, NumFactors);
            y.InitNormal(InitMean, InitStdDev);

            // set factors to zero for items without training examples
            for (int i = 0; i < ratings.CountByItem.Count; i++)
                if (ratings.CountByItem[i] == 0)
                    y.SetRowToOneValue(i, 0);
            for (int i = ratings.CountByItem.Count; i <= MaxItemID; i++)
            {
                y.SetRowToOneValue(i, 0);
                item_factors.SetRowToOneValue(i, 0);
            }

            // set factors to zero for users without training examples (rest is done in MatrixFactorization.cs)
            for (int u = ratings.CountByUser.Count; u <= MaxUserID; u++)
                p.SetRowToOneValue(u, 0);

            user_bias = new float[MaxUserID + 1];
            item_bias = new float[MaxItemID + 1];
        }
开发者ID:Spirit-Dongdong,项目名称:MyMediaLite,代码行数:27,代码来源:SVDPlusPlus.cs

示例6: InitModel

        ///
        protected override void InitModel()
        {
            x = new Matrix<float>(MaxUserID + 1, NumFactors);
            x.InitNormal(InitMean, InitStdDev);

            // set factors to zero for users without training examples
            for (int user_id = 0; user_id < x.NumberOfRows; user_id++)
                if (user_id > ratings.MaxUserID || ratings.CountByUser[user_id] == 0)
                    x.SetRowToOneValue(user_id, 0);

            base.InitModel();
        }
开发者ID:bemde,项目名称:MyMediaLite,代码行数:13,代码来源:SigmoidUserAsymmetricFactorModel.cs

示例7: InitModel

        ///
        protected internal override void InitModel()
        {
            y = new Matrix<float>(MaxItemID + 1, NumFactors);
            y.InitNormal(InitMean, InitStdDev);

            // set factors to zero for items without training examples
            for (int item_id = 0; item_id < y.NumberOfRows; item_id++)
                if (item_id > ratings.MaxItemID || ratings.CountByItem[item_id] == 0)
                    y.SetRowToOneValue(item_id, 0);

            base.InitModel();
        }
开发者ID:Spirit-Dongdong,项目名称:MyMediaLite,代码行数:13,代码来源:SigmoidItemAsymmetricFactorModel.cs

示例8: InitModel

        /// <summary>Initialize the model data structure</summary>
        protected virtual void InitModel()
        {
            // init factor matrices
            user_factors = new Matrix<float>(MaxUserID + 1, NumFactors);
            item_factors = new Matrix<float>(MaxItemID + 1, NumFactors);
            user_factors.InitNormal(InitMean, InitStdDev);
            item_factors.InitNormal(InitMean, InitStdDev);

            // set factors to zero for users and items without training examples
            for (int u = 0; u < ratings.CountByUser.Count; u++)
                if (ratings.CountByUser[u] == 0)
                    user_factors.SetRowToOneValue(u, 0);
            for (int i = 0; i < ratings.CountByItem.Count; i++)
                if (ratings.CountByItem[i] == 0)
                    item_factors.SetRowToOneValue(i, 0);
        }
开发者ID:mvreg,项目名称:MyMediaLite,代码行数:17,代码来源:ThreadSafeMatrixFactorization.cs

示例9: LearnUserAttributeToFactorMapping

        void LearnUserAttributeToFactorMapping()
        {
            // no mapping of no user attributes present
            if (user_attributes.NumberOfEntries == 0)
                return;

            // create attribute-to-factor weight matrix
            this.user_attribute_to_factor = new Matrix<float>(NumUserAttributes + 1, num_factors);
            Console.Error.WriteLine("num_user_attributes=" + NumUserAttributes);
            // store the results of the different runs in the following array
            var old_user_attribute_to_factor = new Matrix<float>[num_init_mapping];

            Console.Error.WriteLine("Will use {0} examples ...", num_iter_mapping * MaxUserID);

            var old_rmse_per_factor = new double[num_init_mapping][];

            for (int h = 0; h < num_init_mapping; h++)
            {
                user_attribute_to_factor.InitNormal(InitMean, InitStdDev);
                Console.Error.WriteLine("----");

                for (int i = 0; i < num_iter_mapping * MaxUserID; i++)
                    UpdateUserMapping();
                ComputeUserMappingFit();

                old_user_attribute_to_factor[h] = new Matrix<float>(user_attribute_to_factor);
                old_rmse_per_factor[h] = ComputeUserMappingFit();
            }

            var min_rmse_per_factor = new double[num_factors];
            for (int i = 0; i < num_factors; i++)
                min_rmse_per_factor[i] = double.MaxValue;
            var best_factor_init = new int[num_factors];

            // find best factor mappings:
            for (int i = 0; i < num_init_mapping; i++)
            {
                for (int j = 0; j < num_factors; j++)
                {
                    if (old_rmse_per_factor[i][j] < min_rmse_per_factor[j])
                    {
                        min_rmse_per_factor[j] = old_rmse_per_factor[i][j];
                        best_factor_init[j]    = i;
                    }
                }
            }

            // set the best weight combinations for each factor mapping
            for (int i = 0; i < num_factors; i++)
            {
                Console.Error.WriteLine("Factor {0}, pick {1}", i, best_factor_init[i]);
                user_attribute_to_factor.SetColumn(i, old_user_attribute_to_factor[best_factor_init[i]].GetColumn(i));
            }

            Console.Error.WriteLine("----");
            ComputeUserMappingFit();

            ComputeFactorsForNewUsers();
        }
开发者ID:wendelad,项目名称:RecSys,代码行数:59,代码来源:BPRMF_Mapping.cs

示例10: InitModel

        ///
        protected internal override void InitModel()
        {
            base.InitModel ();

            p = new Matrix<float> (MaxUserID + 1, NumFactors);
            p.InitNormal (InitMean, InitStdDev);
            y = new Matrix<float> (MaxItemID + 1, NumFactors);
            y.InitNormal (InitMean, InitStdDev);

            // set factors to zero for items without training examples
            for (int i = 0; i < ratings.CountByItem.Count; i++)
                if (ratings.CountByItem [i] == 0)
                    y.SetRowToOneValue (i, 0);
            for (int i = ratings.CountByItem.Count; i <= MaxItemID; i++) {
                y.SetRowToOneValue (i, 0);
                item_factors.SetRowToOneValue (i, 0);
            }
            // set factors to zero for users without training examples (rest is done in MatrixFactorization.cs)
            for (int u = ratings.CountByUser.Count; u <= MaxUserID; u++) {
                p.SetRowToOneValue (u, 0);
            }
            user_bias = new float[MaxUserID + 1];
            item_bias = new float[MaxItemID + 1];

            h = new Matrix<float>[AdditionalUserAttributes.Count + 1];
            h [0] = new Matrix<float> (UserAttributes.NumberOfColumns, ItemAttributes.NumberOfColumns);
            h [0].InitNormal (InitMean, InitStdDev);
            for (int d = 0; d < AdditionalUserAttributes.Count; d++) {
                h [d + 1] = new Matrix<float> (AdditionalUserAttributes [d].NumberOfColumns, ItemAttributes.NumberOfColumns);
                h [d + 1].InitNormal (InitMean, InitStdDev);
            }
        }
开发者ID:wendelad,项目名称:RecSys,代码行数:33,代码来源:DemoMFUserItemAtt.cs

示例11: InitModel

        ///
        protected override void InitModel()
        {
            base.InitModel ();

            user_factors = null;
            item_factors = null;
            p = new Matrix<float> (MaxUserID + 1, NumFactors);
            p.InitNormal (InitMean, InitStdDev);
            q = new Matrix<float> (MaxItemID + 1, NumFactors);
            q.InitNormal (InitMean, InitStdDev);

            Console.Write("Learning attributes...");
            BPRLinear learnAttr = new BPRLinear();
            learnAttr.Feedback = Feedback;
            learnAttr.ItemAttributes = item_attributes;
            learnAttr.NumIter = NumIter;//10;
            learnAttr.LearnRate = LearnRate;//0.05f;
            learnAttr.Regularization = 0.015f;//0.001f;
            learnAttr.Train();
            item_attribute_weight_by_user = learnAttr.ItemAttributeWeights;
            learnAttr = null;
            Console.WriteLine ("Done");
        }
开发者ID:wendelad,项目名称:RecSys,代码行数:24,代码来源:BPRMFAttr.cs

示例12: InitModel

        ///
        protected override void InitModel()
        {
            base.InitModel();

            p = new Matrix<float>(MaxUserID + 1, NumFactors);
            p.InitNormal(InitMean, InitStdDev);
            y = new Matrix<float>(MaxItemID + 1, NumFactors);
            y.InitNormal(InitMean, InitStdDev);

            // set factors to zero for items without training examples
            for (int i = 0; i <= MaxItemID; i++)
                if (ratings.CountByItem[i] == 0)
                    y.SetRowToOneValue(i, 0);

            user_bias = new float[MaxUserID + 1];
            item_bias = new float[MaxItemID + 1];
        }
开发者ID:dylanhogg,项目名称:MyMediaLite,代码行数:18,代码来源:SVDPlusPlus.cs


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