本文整理汇总了C#中System.Matrix.SetRowToOneValue方法的典型用法代码示例。如果您正苦于以下问题:C# Matrix.SetRowToOneValue方法的具体用法?C# Matrix.SetRowToOneValue怎么用?C# Matrix.SetRowToOneValue使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Matrix
的用法示例。
在下文中一共展示了Matrix.SetRowToOneValue方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: TestSetRowToOneValue
[Test()] public void TestSetRowToOneValue()
{
var matrix = new Matrix<int>(5, 5);
int[] row = { 1, 2, 3, 4, 5 };
for (int i = 0; i < 5; i++)
matrix.SetRow(i, row);
matrix.SetRowToOneValue(3, 10);
int[] testrow = { 10, 10, 10, 10, 10 };
Assert.AreEqual(testrow, matrix.GetRow(3));
}
示例2: 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);
}
示例3: 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];
}
示例4: 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();
}
示例5: 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();
}
示例6: 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);
}
示例7: 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);
}
}
示例8: 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];
}