Creates an unconstrained (SVD/PCA) factorization layer. No non-negativity constraint by default; factors are signed.
Usage
svd_layer(
input,
k,
L1 = 0,
L2 = 0,
L21 = 0,
angular = 0,
upper_bound = 0,
center = FALSE,
scale = FALSE,
method = c("auto", "deflation", "krylov", "lanczos", "irlba", "randomized"),
mask = NULL,
robust = FALSE,
W = NULL,
H = NULL,
name = NULL,
...
)Arguments
- input
An
fn_node(input, shared, condition, or another layer).- k
Factorization rank.
- L1
L1 penalty (shared by U and V unless overridden). Default 0.
- L2
L2 penalty. Default 0.
- L21
Group sparsity penalty. Default 0.
- angular
Orthogonality penalty. Default 0.
- upper_bound
Box constraint. Default 0.
- center
Center columns before factorization (PCA mode). Default FALSE.
- scale
Scale columns to unit variance. Default FALSE.
- method
SVD algorithm:
"auto","deflation","krylov","lanczos","irlba", or"randomized". Default"auto".- mask
Masking mode: NULL (none),
"zeros", or a sparse mask matrix. Seesvdfor details.- robust
Use robust loss. Default FALSE.
- W
Optional
W()config to override U-specific settings.- H
Optional
H()config to override V-specific settings.- name
Optional layer name (for results access).
- ...
Additional arguments forwarded to
svdat fit time. Supports:convergence,cv_seed,patience,k_max,graph_U,graph_V,graph_lambda,threads. See?svdfor the complete list.
Details
SVD-specific parameters (center, scale, method)
control the SVD algorithm directly. Regularization parameters
and ... are forwarded to svd at fit time.
Examples
data(aml)
inp <- factor_input(aml)
layer <- svd_layer(inp, k = 5)
# PCA with centering and scaling
pca_layer <- svd_layer(inp, k = 10, center = TRUE, scale = TRUE)