Hi @ptrblck One question.
Since different frameworks might converge differently. I was mostly looking into how data augmentation happens in Caffe and PyTorch. In Caffe C++ random numbers (uniform distribution) are generated for data augmentation as in the code below:

  
      github.com
  
  
    davheld/GOTURN/blob/ae8df641079980b6c7b05c27d0bf501becc713d4/src/helper/bounding_box.cpp#L274 1

  num_tries_width++;
}


// Find a height scaling factor for the new crop window, thresholding the scale to stay within a reasonable window.
double new_height = -1;
int num_tries_height = 0;
while ((new_height < 0 || new_height > image.rows - 1) && num_tries_height < kMaxNumTries) {
  // Sample.
  double height_scale_factor;
  if (shift_motion_model) {
    height_scale_factor = max(min_scale, min(max_scale, sample_exp_two_sided(lambda_scale_frac)));
  } else {
    const double rand_num = sample_rand_uniform();
    height_scale_factor = rand_num * (max_scale - min_scale) + min_scale;
  }
  // Expand height by scaling factor.
  new_height = height * (1 + height_scale_factor);
  // Ensure that height stays within valid limits.
  new_height = max(1.0, min(static_cast<double>(image.rows - 1), new_height));
  num_tries_height++;
}



  
  
    
    
  
  



  
      github.com
  
  
    davheld/GOTURN/blob/ae8df641079980b6c7b05c27d0bf501becc713d4/src/helper/helper.cpp#L133 2

  // http://www.cplusplus.com/forum/beginner/7445/
  return (rand() + 1) / (static_cast<double>(RAND_MAX) + 2);
}


double sample_exp(const double lambda) {
  // Sample from an exponential - http://stackoverflow.com/questions/11491458/how-to-generate-random-numbers-with-exponential-distribution-with-mean
  const double rand_uniform = sample_rand_uniform();
  return -log(rand_uniform) / lambda;
}


double sample_exp_two_sided(const double lambda) {
  // Determine which side of the two-sided exponential we are sampling from.
  const double pos_or_neg = (rand() % 2 == 0) ? 1 : -1;


  // Sample from an exponential - http://stackoverflow.com/questions/11491458/how-to-generate-random-numbers-with-exponential-distribution-with-mean
  const double rand_uniform = sample_rand_uniform();
  return log(rand_uniform) / lambda * pos_or_neg;
}



  
  
    
    
  
  


Data fetching does happen in a single process, whereas in PyTorch code, I am using num_workers > 0.
I use PyTorch API to generate random numbers as below and can I assume its thread-safe?
import math

import torch

RAND_MAX = 2147483647


def sample_rand_uniform():
    """TODO: Docstring for sample_rand_uniform.
    :arg1: TODO
    :returns: TODO
    """
    # return ((random.randint(0, RAND_MAX) + 1) * 1.0) / (RAND_MAX + 2)
    rand_num = torch.randint(RAND_MAX, (1, 1)).item()
    return ((rand_num + 1) / (RAND_MAX + 2))
    # return torch.rand(1).item()


def sample_exp_two_sides(lambda_):
    """TODO: Docstring for sample_exp_two_sides.
    :returns: TODO
    """

    # pos_or_neg = random.randint(0, RAND_MAX)
    pos_or_neg = torch.randint(RAND_MAX, (1, 1)).item()
    if (pos_or_neg % 2) == 0:
        pos_or_neg = 1
    else:
        pos_or_neg = -1

    rand_uniform = sample_rand_uniform()
    return math.log(rand_uniform) / (lambda_ * pos_or_neg)