MCPcopy Create free account
hub / github.com/pytorch/tutorials / Symmetric

Class Symmetric

intermediate_source/parametrizations.py:98–100  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

96# Let's start by reimplementing the code above using ``torch.nn.utils.parametrize``.
97# The only thing that we have to do is to write the parametrization as a regular ``nn.Module``
98class Symmetric(nn.Module):
99 def forward(self, X):
100 return X.triu() + X.triu(1).transpose(-1, -2)
101
102###############################################################################
103# This is all we need to do. Once we have this, we can transform any regular layer into a

Callers 1

Calls

no outgoing calls

Tested by

no test coverage detected