You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
<emclass="property"><spanclass="pre">class</span><spanclass="w"></span></em><spanclass="sig-prename descclassname"><spanclass="pre">torchjd.autogram.</span></span><spanclass="sig-name descname"><spanclass="pre">Engine</span></span><spanclass="sig-paren">(</span><emclass="sig-param"><spanclass="n"><spanclass="pre">modules</span></span></em>, <emclass="sig-param"><spanclass="n"><spanclass="pre">batch_dim</span></span></em><spanclass="sig-paren">)</span><aclass="reference external" href="https://github.com/TorchJD/torchjd/blob/main/src/torchjd/autogram/_engine.py#L41-L318"><spanclass="viewcode-link"><spanclass="pre">[source]</span></span></a><aclass="headerlink" href="#torchjd.autogram.Engine" title="Link to this definition">¶</a></dt>
254
+
<emclass="property"><spanclass="pre">class</span><spanclass="w"></span></em><spanclass="sig-prename descclassname"><spanclass="pre">torchjd.autogram.</span></span><spanclass="sig-name descname"><spanclass="pre">Engine</span></span><spanclass="sig-paren">(</span><emclass="sig-param"><spanclass="o"><spanclass="pre">*</span></span><spanclass="n"><spanclass="pre">modules</span></span></em>, <emclass="sig-param"><spanclass="n"><spanclass="pre">batch_dim</span></span></em><spanclass="sig-paren">)</span><aclass="reference external" href="https://github.com/TorchJD/torchjd/blob/main/src/torchjd/autogram/_engine.py#L40-L318"><spanclass="viewcode-link"><spanclass="pre">[source]</span></span></a><aclass="headerlink" href="#torchjd.autogram.Engine" title="Link to this definition">¶</a></dt>
255
255
<dd><p>Engine to compute the Gramian of the Jacobian of some tensor with respect to the direct
256
256
parameters of all provided modules. It is based on Algorithm 3 of <aclass="reference external" href="https://arxiv.org/pdf/2406.16232">Jacobian Descent For
257
257
Multi-Objective Optimization</a> but goes even further:</p>
@@ -270,8 +270,9 @@ <h1>Engine<a class="headerlink" href="#engine" title="Link to this heading">¶</
<li><p><strong>modules</strong> (<spanclass="sphinx_autodoc_typehints-type"><aclass="reference external" href="https://docs.python.org/3/library/collections.abc.html#collections.abc.Iterable" title="(in Python v3.14)"><codeclass="xref py py-class docutils literal notranslate"><spanclass="pre">Iterable</span></code></a>[<aclass="reference external" href="https://docs.pytorch.org/docs/stable/generated/torch.nn.Module.html#torch.nn.Module" title="(in PyTorch v2.8)"><codeclass="xref py py-class docutils literal notranslate"><spanclass="pre">Module</span></code></a>]</span>) – A collection of modules whose direct (non-recursive) parameters will contribute
274
-
to the Gramian of the Jacobian.</p></li>
273
+
<li><p><strong>modules</strong> (<spanclass="sphinx_autodoc_typehints-type"><aclass="reference external" href="https://docs.pytorch.org/docs/stable/generated/torch.nn.Module.html#torch.nn.Module" title="(in PyTorch v2.8)"><codeclass="xref py py-class docutils literal notranslate"><spanclass="pre">Module</span></code></a></span>) – The modules whose parameters will contribute to the Gramian of the Jacobian.
274
+
Several modules can be provided, but it’s important that none of them is a child module of
275
+
another of them.</p></li>
275
276
<li><p><strong>batch_dim</strong> (<spanclass="sphinx_autodoc_typehints-type"><aclass="reference external" href="https://docs.python.org/3/library/functions.html#int" title="(in Python v3.14)"><codeclass="xref py py-class docutils literal notranslate"><spanclass="pre">int</span></code></a> | <aclass="reference external" href="https://docs.python.org/3/library/constants.html#None" title="(in Python v3.14)"><codeclass="xref py py-obj docutils literal notranslate"><spanclass="pre">None</span></code></a></span>) – If the modules work with batches and process each batch element independently,
276
277
then many intermediary Jacobians are sparse (block-diagonal), which allows for a substantial
277
278
memory optimization by backpropagating a squashed Jacobian instead. This parameter indicates
@@ -300,7 +301,7 @@ <h1>Engine<a class="headerlink" href="#engine" title="Link to this heading">¶</
<spanclass="n">inputs</span><spanclass="o">=</span><spanclass="n">torch</span><spanclass="o">.</span><spanclass="n">randn</span><spanclass="p">(</span><spanclass="mi">8</span><spanclass="p">,</span><spanclass="mi">16</span><spanclass="p">,</span><spanclass="mi">10</span><spanclass="p">)</span><spanclass="c1"># 8 batches of 16 random input vectors of length 10</span>
280
280
<spanclass="n">task1_targets</span><spanclass="o">=</span><spanclass="n">torch</span><spanclass="o">.</span><spanclass="n">randn</span><spanclass="p">(</span><spanclass="mi">8</span><spanclass="p">,</span><spanclass="mi">16</span><spanclass="p">)</span><spanclass="c1"># 8 batches of 16 targets for the first task</span>
0 commit comments