Dropout method

Matrix Dropout(
  1. double rate
)

Implementation

Matrix Dropout(double rate) {
  if (rate < 0 || rate > 1) {
    throw Exception("Dropout rate must be between 0 and 1");
  }
  Random random = Random();
  //usually a mask is applied
  return performFunction((a) {
    if (random.nextDouble() < rate) {
      return 0.0;
    }
    //scale the values to account for the dropout
    return a * (1.0 / (1.0 - rate));
  });
}