getBatch function

(List<int>, List<int>) getBatch(
  1. List<int> data,
  2. int blockSize
)

Implementation

(List<int>, List<int>) getBatch(List<int> data, int blockSize) {
  final rng = math.Random();
  // Pick a random starting index
  int start = rng.nextInt(data.length - blockSize - 1);

  // X is the sequence, Y is the same sequence shifted by 1
  final x = data.sublist(start, start + blockSize);
  final y = data.sublist(start + 1, start + blockSize + 1);

  return (x, y);
}