| 241 | # But the matrix exponential also maps the skew-symmetric matrices to the orthogonal matrices. |
| 242 | # Using these two facts, we may reuse the parametrizations before to our advantage |
| 243 | class MatrixExponential(nn.Module): |
| 244 | def forward(self, X): |
| 245 | return torch.matrix_exp(X) |
| 246 | |
| 247 | layer_orthogonal = nn.Linear(3, 3) |
| 248 | parametrize.register_parametrization(layer_orthogonal, "weight", Skew()) |