本文整理汇总了C#中System.Matrix.Select方法的典型用法代码示例。如果您正苦于以下问题:C# Matrix.Select方法的具体用法?C# Matrix.Select怎么用?C# Matrix.Select使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Matrix
的用法示例。
在下文中一共展示了Matrix.Select方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetPalette
internal Matrix[] GetPalette()
{
Matrix[] m = new Matrix[256];
m = m.Select(me => Matrix.Identity).ToArray();
int i = 0;
foreach (Node n in JointNodes)
{
var node = n;
Matrix currentMat = node.PreComputed;
while (node.Parent != null)
{
node = node.Parent;
currentMat *= node.PreComputed;
}
m[i] = BindMatrix * InverseBindMatrix[i] * currentMat;
i++;
}
return m;
}
示例2: Init
internal void Init(SharpModel model)
{
Matrix[] m = new Matrix[256];
m = m.Select(me => Matrix.Identity).ToArray();
List<Matrix> tempMatrices = new List<Matrix>();
for (int i = 0; i < JointNames.Count; i++)
{
string s = JointNames[i];
var node = model.GetNodeByName(s);
JointNodes.Add(node);
}
}
示例3: TrainTestSplit
/// <summary>
/// Split arrays or matrices into random train and test subsets
/// </summary>
/// <param name="arrays">Array of matrices with same row number.</param>
/// <param name="testSize">Should be between 0.0 and 1.0 and represent the
/// proportion of the dataset to include in the test split. If <c>null</c>,
/// the value is automatically set to the complement of the train size.
/// If train size is also <c> null</c>, test size is set to 0.25.</param>
/// <param name="trainSize">Should be between 0.0 and 1.0 and represent the
/// proportion of the dataset to include in the train split. If <c>null</c>,
/// the value is automatically set to the complement of the test size.</param>
/// <param name="randomState">Pseudo-random number generator state used for random sampling.</param>
/// <returns>List containing train-test split of input array.</returns>
public static IList<Tuple<Matrix<double>, Matrix<double>>> TrainTestSplit(
Matrix<double>[] arrays,
double? testSize = null,
double? trainSize = null,
Random randomState = null)
{
/*
Examples
--------
>>> import numpy as np
>>> from sklearn.cross_validation import train_test_split
>>> a, b = np.arange(10).reshape((5, 2)), range(5)
>>> a
array([[0, 1],
[2, 3],
[4, 5],
[6, 7],
[8, 9]])
>>> list(b)
[0, 1, 2, 3, 4]
>>> a_train, a_test, b_train, b_test = train_test_split(
... a, b, test_size=0.33, random_state=42)
...
>>> a_train
array([[4, 5],
[0, 1],
[6, 7]])
>>> b_train
array([2, 0, 3])
>>> a_test
array([[2, 3],
[8, 9]])
>>> b_test
array([1, 4])
*/
int nArrays = arrays.Length;
if (nArrays == 0)
{
throw new ArgumentException("At least one array required as input");
}
if (arrays.Any(a => a.RowCount != arrays[0].RowCount))
{
throw new ArgumentException("All arrays must have same row count");
}
if (testSize == null && trainSize == null)
{
testSize = 0.25;
}
int nSamples = arrays[0].RowCount;
var cv = ShuffleSplit(
nSamples,
testSize: testSize,
trainSize: trainSize,
randomState: randomState);
var r = cv.First();
int[] train = r.TrainIndices;
int[] test = r.TestIndices;
return arrays.Select(a => Tuple.Create(a.RowsAt(train), a.RowsAt(test))).ToList();
}