Exemplo n.º 1
0
 public virtual DataBatch GetNextBatch()
 {
     _currentBatch++;
     if (_currentBatch > Batches.Count)
     {
         _currentBatch = 1;
         _currentEpoch++;
     }
     var batch = Batches[_currentBatch-1];
     batch.EpocNo = _currentEpoch;
     batch.BatchNo = _currentBatch;
     CurrentBatch = batch;
     return batch;
 }
Exemplo n.º 2
0
        public virtual DataBatch GetNextBatch()
        {
            _currentBatch++;
            if (_currentBatch > Batches.Count)
            {
                _currentBatch = 1;
                _currentEpoch++;
            }
            var batch = Batches[_currentBatch - 1];

            batch.EpocNo  = _currentEpoch;
            batch.BatchNo = _currentBatch;
            CurrentBatch  = batch;
            return(batch);
        }
        public void LoadNextBatchSet()
        {
            if (_currentEpoch >= 0)
            {
                for (int setIdx = 0; setIdx < Constants.BATCHES_PER_SET; setIdx++)
                {
                    DataBatch batch;
                    if ((Batches == null) || (Batches.Count < (Constants.BATCHES_PER_SET)))
                    {
                        batch = new DataBatch(Constants.TOTAL_VALUE_COUNT, 1, sparse: true);
                        Batches.Add(batch);
                    }
                    else
                    {
                        batch = Batches[setIdx];
                    }

                    for (var minibatchIdx = 0; minibatchIdx < Constants.MINIBATCH_SIZE; minibatchIdx++)
                    {
                        OneHotRecordReadOnly rec = _records[_recNo];
                        rec.CopyDataToSparseArray(batch.SparseIndices, batch.SparseValues, minibatchIdx);
                        batch.Labels[minibatchIdx] = rec.Label;
                        _recNo++;
                        if (_recNo >= _records.Count)
                        {
                            _recNo = 0;
                            if (_totalBatchCount == 0) _totalBatchCount = _batchesRead;
                            _batchesRead = 0;
                            _currentEpoch++;
                            CurrentEpochBatch = 0;
                            if (_shuffle) _records.Shuffle();
                        }
                        _batchesRead++;
                    }
                }
            }
           
            _currentBatch = 0;
            CurrentSet++;
            _loaded = true;
        }