Skip to contents

A projection, not a penalty: each weight vector keeps its direction and only its length is capped at r. axis follows numpy on a matrix: 0 = down columns, 1 (or -1) = across rows; NULL treats the whole array as one vector.

Usage

morie_geron_max_norm(w, r, axis = NULL)

Arguments

w

Vector or matrix.

r

Positive radius.

axis

NULL, 0, 1 or -1.

Value

List with w, norm_before, norm_after, clipped, n_clipped, r, estimate, n.

Examples

morie_geron_max_norm(w = c(1, 2, 3, 4, 5, 6, 7, 8), r = 5L)
#> $w
#> [1] 0.35007 0.70014 1.05021 1.40028 1.75035 2.10042 2.45049 2.80056
#> 
#> $norm_before
#> [1] 14.28286
#> 
#> $norm_after
#> [1] 5
#> 
#> $clipped
#> [1] TRUE
#> 
#> $n_clipped
#> [1] 1
#> 
#> $r
#> [1] 5
#> 
#> $estimate
#> [1] 5
#> 
#> $n
#> [1] 8
#> 
#> $method
#> [1] "Max-norm regularization (projection onto the l2 ball)"
#>