Ejemplo n.º 1
0
        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;
        }
Ejemplo n.º 2
0
        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);
            }
        }
Ejemplo n.º 3
0
        /// <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();
        }