Applies dropout to the input data for regularization during training. The dropout rate determines the probability of retaining a unit.

dropout_layer(x, dropout = 0, seed = 42)

Arguments

x

A numeric matrix of input data.

dropout

A numeric value between 0 and 1 representing the dropout rate. Default is 0.

seed

An integer seed for random number generation. Default is 42.

Value

A matrix of the same shape as x with dropout applied.

Examples

# Apply dropout to a matrix
x <- matrix(runif(20), nrow = 5)
dropout_layer(x, dropout = 0.5)
#>            [,1]      [,2]       [,3]      [,4]
#> [1,] 0.16150028 0.9327870 0.00000000 0.3913397
#> [2,] 1.66866607 0.9955548 0.34988125 0.8070762
#> [3,] 0.00000000 0.0000000 0.06848267 0.0000000
#> [4,] 0.31441688 1.4657640 0.00000000 0.0000000
#> [5,] 0.01479888 1.5450430 0.00000000 1.9510957