learn2learn.nn¶
Additional torch.nn.Module
s frequently used for metalearning.
Lambda¶
1 

Description
Utility class to create a wrapper based on a lambda function.
Arguments
 lmb (callable)  The function to call in the forward pass.
Example
1 2 3 4 

Flatten¶
1 

Description
Utility Module to flatten inputs to (batch_size, 1)
shape.
Example
1 2 3 4 

Scale¶
1 

Description
A perparameter scaling factor with learnable parameter.
Arguments
 shape (int or tuple)  The shape of the scaling matrix.
 alpha (float, optional, default=1.0)  Initial value for the scaling factor.
Example
1 2 3 

KroneckerLinear¶
1 

Description
A linear transformation whose parameters are expressed as a Kronecker product.
This Module maps an input vector to such that:
where and are the learnable Kronecker factors. This implementation can reduce the memory requirement for large linear mapping from to , but forces .
The matrix is initialized as the identity, and the bias as a zero vector.
Arguments
 n (int)  Dimensionality of the left Kronecker factor.
 m (int)  Dimensionality of the right Kronecker factor.
 bias (bool, optional, default=True)  Whether to include the bias term.
 psd (bool, optional, default=False)  Forces the matrix to be positive semidefinite if True.
 device (device, optional, default=None)  The device on which to instantiate the Module.
References
 Jose et al. 2018. "Kronecker recurrent units".
 Arnold et al. 2019. "When MAML can adapt fast and how to assist when it cannot".
Example
1 2 3 4 5 

KroneckerRNN¶
1 

Description
Implements a recurrent neural network whose matrices are parameterized via their Kronecker factors.
(See KroneckerLinear
for details.)
Arguments
 n (int)  Dimensionality of the left Kronecker factor.
 m (int)  Dimensionality of the right Kronecker factor.
 bias (bool, optional, default=True)  Whether to include the bias term.
 sigma (callable, optional, default=None)  The activation function.
References
 Jose et al. 2018. "Kronecker recurrent units".
Example
1 2 3 4 5 6 

KroneckerLSTM¶
1 

Description
Implements an LSTM using a factorization similar to the one of
KroneckerLinear
.
Arguments
 n (int)  Dimensionality of the left Kronecker factor.
 m (int)  Dimensionality of the right Kronecker factor.
 bias (bool, optional, default=True)  Whether to include the bias term.
 sigma (callable, optional, default=None)  The activation function.
References
 Jose et al. 2018. "Kronecker recurrent units".
Example
1 2 3 4 5 6 
