 
 std::vector<size_t> SGD::CreateShuffle(size_t numExamples) const {
   vector<size_t> ret(numExamples);
-  std::iota(ret.begin(), ret.end(), 1);
+  std::iota(ret.begin(), ret.end(), 0);
   std::random_shuffle ( ret.begin(), ret.end() );
-
+  /*
+  cerr << "shuffled" << endl;
   for (size_t i = 0; i < ret.size(); ++i) {
-	  cerr << ret[i] << " ";
+    cerr << ret[i] << " ";
   }
-
+  */
   return ret;
 }
 

		const std::vector<size_t> &shuffle,
		Tensor& xt,
		Tensor& yt) {

  std::vector<float> x(xData_.begin() + startId * numFeatures_,
                       xData_.begin() + endId * numFeatures_);
  std::vector<float> y(yData_.begin() + startId * numClasses_,
                       yData_.begin() + endId * numClasses_);
  /*
  std::vector<float> x(batchSize * numFeatures_);
  std::vector<float> y(batchSize * numClasses_);

  std::vector<float>::iterator startXIter = x.begin();
  std::vector<float>::iterator startYIter = y.begin();

  for (size_t i = startId; i < endId; ++i) {
    size_t startXDataId = i * numFeatures_;
    size_t startYDataId = i * numClasses_;

    size_t endXDataId = startXDataId + batchSize * numFeatures_;
    size_t endYDataId = startYDataId + batchSize * numClasses_;

    std::copy(xData_.begin() + startXDataId,
        xData_.begin() + endXDataId,
        startXIter);

    std::copy(yData_.begin() + startYDataId,
        yData_.begin() + endYDataId,
        startYIter);

    startXIter += batchSize * numFeatures_;
    startYIter += batchSize * numClasses_;
  }
  */
  xt.set(x);
  yt.set(y);
}

  Tensor xt({(int)maxBatchSize_, (int)numExamples}, 0.0f);
  Tensor yt({(int)maxBatchSize_, (int)numClasses_}, 0.0f);

  vector<size_t> shuffle = CreateShuffle(numExamples);
  //vector<size_t> shuffle;

  for (size_t numEpoch = 0; numEpoch < epochs_; ++numEpoch) {
    std::cerr << "Starting epoch #" << numEpoch << std::endl;
