A set transformer uses induced self-attention mechanism to efficiently process variable-sized sets while maintaining permutation invariance.
Usage
set_transformer(
num_blocks,
d_model,
nhead,
dim_feedforward,
num_inds = 16L,
dropout = 0,
activation = "gelu",
norm_first = TRUE,
bias_free_ln = FALSE,
ssmax = FALSE,
recompute = FALSE
)Arguments
- num_blocks
Integer. Number of induced self-attention blocks in the stack.
- d_model
Integer. Model dimension.
- nhead
Integer. Number of attention heads and should be a divisor of
d_model.- dim_feedforward
Integer. Dimension of the feedforward network in each block.
- num_inds
Integer, default
16L. Number of inducing points used in self-attention blocks.- dropout
Float, default
0. Dropout probability.- activation
Character string or unary function, default
"gelu". The activation function used in the feedforward network.- norm_first
Logical, default
TRUE. IfTRUE, uses pre-norm architecture (LayerNorm before attention and feedforward).- bias_free_ln
Logical, default
FALSE. IfTRUE, removes bias from all LayerNorm layers.- ssmax
Logical or character string, default
FALSE. Type of scalable softmax to use in attention. Note that only the first attention layer of the induced self-attention blocks uses SSMax. IfTRUE, equivalent to"qassmax-mlp-elementwise". IfFALSE, equivalent to"none". If a string, uses the specified scalable softmax type. Options include:"none","ssmax","ssmax-mlp","ssmax-mlp-elementwise","qassmax-mlp","qassmax-mlp-elementwise".- recompute
Logical, default
FALSE. IfTRUE, uses gradient checkpointing to save memory at the cost of additional computation.
References
Lee et al. "Set Transformer: A Framework for Attention-based Permutation-Invariant Neural Networks", ICML 2019.