public Tuple <Matrix <float>, Vector <float> > BuildData(List <TrainingInstance> trainingInstances)
        {
            IState[] states = trainingInstances.Select(x => x.State).ToArray();

            double[] pathCosts = trainingInstances.Select(x => x.Response).ToArray();

            Matrix <float> trainingData = DenseMatrix.Create(states.Length, numInputs, 0);

            for (int r = 0; r < trainingData.RowCount; r++)
            {
                IState state = states[r];

                byte[] stateArr = state.Arr;

                int count = 0;

                for (byte i = 0; i < stateArr.Length; i++)
                {
                    int index = Array.IndexOf(stateArr, i);

                    var coord = SlidingPuzzle.IndexToCoord(index);

                    trainingData[r, count + coord.Item1 - 1] = 1;

                    trainingData[r, count + dim + coord.Item2 - 1] = 1;

                    count += dim + dim;
                }
            }

            Vector <float> response = DenseVector.Create(pathCosts.Length, 0);

            for (int i = 0; i < pathCosts.Length; i++)
            {
                double y = pathCosts[i];

                if (responseFunc != null)
                {
                    y = responseFunc(y);
                }

                response[i] = (float)y;
            }

            return(new Tuple <Matrix <float>, Vector <float> >(trainingData, response));
        }