mlvbench 1.0.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- mlvbench-1.0.0/.cache/.gitignore +1 -0
- mlvbench-1.0.0/.cache/10063063919107421344 +247 -0
- mlvbench-1.0.0/.cache/11345666923742321217 +85 -0
- mlvbench-1.0.0/.cache/1141850114958761227 +4 -0
- mlvbench-1.0.0/.cache/11456387269464706988 +4 -0
- mlvbench-1.0.0/.cache/11835155072979095136 +4 -0
- mlvbench-1.0.0/.cache/11954259690690593998 +4 -0
- mlvbench-1.0.0/.cache/12982394924984236030 +4 -0
- mlvbench-1.0.0/.cache/13237322144914190747 +134 -0
- mlvbench-1.0.0/.cache/13953322240513355202 +166 -0
- mlvbench-1.0.0/.cache/15004862324880043465 +680 -0
- mlvbench-1.0.0/.cache/15251523919443859938 +69 -0
- mlvbench-1.0.0/.cache/15269489070391992075 +1419 -0
- mlvbench-1.0.0/.cache/15530694053516260604 +53 -0
- mlvbench-1.0.0/.cache/15866798469499556265 +231 -0
- mlvbench-1.0.0/.cache/15915925135937848661 +4 -0
- mlvbench-1.0.0/.cache/17421211722364188045 +4 -0
- mlvbench-1.0.0/.cache/17529146015742099530 +4 -0
- mlvbench-1.0.0/.cache/2409223974408997482 +4 -0
- mlvbench-1.0.0/.cache/2463438938946544943 +102 -0
- mlvbench-1.0.0/.cache/2539952211682570504 +182 -0
- mlvbench-1.0.0/.cache/3476900567878811119 +4 -0
- mlvbench-1.0.0/.cache/3541202890535126406 +28 -0
- mlvbench-1.0.0/.cache/3712847496576623335 +4 -0
- mlvbench-1.0.0/.cache/6390507687650244495 +185 -0
- mlvbench-1.0.0/.cache/6980451856348078450 +4 -0
- mlvbench-1.0.0/.cache/7641247536426526517 +445 -0
- mlvbench-1.0.0/.cache/8183860843504946297 +223 -0
- mlvbench-1.0.0/.cache/8469218231258070200 +4 -0
- mlvbench-1.0.0/.cache/8756208354251036245 +4 -0
- mlvbench-1.0.0/.cache/9433222255211511669 +4 -0
- mlvbench-1.0.0/.github/workflows/docs.yml +31 -0
- mlvbench-1.0.0/.gitignore +31 -0
- mlvbench-1.0.0/.python-version +1 -0
- mlvbench-1.0.0/LICENSE +7 -0
- mlvbench-1.0.0/Makefile +26 -0
- mlvbench-1.0.0/PKG-INFO +144 -0
- mlvbench-1.0.0/README.md +97 -0
- mlvbench-1.0.0/docs/API/mlvbench.cache.md +3 -0
- mlvbench-1.0.0/docs/API/mlvbench.datasets.md +3 -0
- mlvbench-1.0.0/docs/API/mlvbench.download.md +3 -0
- mlvbench-1.0.0/docs/API/mlvbench.infrastructure.md +3 -0
- mlvbench-1.0.0/docs/API/mlvbench.models.md +3 -0
- mlvbench-1.0.0/docs/API/mlvbench.monitoring.md +3 -0
- mlvbench-1.0.0/docs/API/mlvbench.probes.md +3 -0
- mlvbench-1.0.0/docs/API/mlvbench.stimuli.shapes.md +3 -0
- mlvbench-1.0.0/docs/API/mlvbench.stimuli.textures.md +3 -0
- mlvbench-1.0.0/docs/API/mlvbench.stimuli.transforms.md +3 -0
- mlvbench-1.0.0/docs/API/mlvbench.tasks.binary_segmentation.md +3 -0
- mlvbench-1.0.0/docs/API/mlvbench.tasks.md +8 -0
- mlvbench-1.0.0/docs/API/mlvbench.trainer.md +3 -0
- mlvbench-1.0.0/docs/index.md +63 -0
- mlvbench-1.0.0/docs/javascripts/mathjax.js +23 -0
- mlvbench-1.0.0/docs/models.md +449 -0
- mlvbench-1.0.0/experiments/figure_ground_shape_cues/README.md +44 -0
- mlvbench-1.0.0/experiments/figure_ground_shape_cues/configs/debug.yaml +12 -0
- mlvbench-1.0.0/experiments/figure_ground_shape_cues/configs/default.yaml +4 -0
- mlvbench-1.0.0/experiments/figure_ground_shape_cues/experiment.py +174 -0
- mlvbench-1.0.0/experiments/figure_ground_shape_cues/launch.py +347 -0
- mlvbench-1.0.0/mlvbench/__init__.py +1 -0
- mlvbench-1.0.0/mlvbench/cache.py +508 -0
- mlvbench-1.0.0/mlvbench/datasets/__init__.py +16 -0
- mlvbench-1.0.0/mlvbench/datasets/_base.py +380 -0
- mlvbench-1.0.0/mlvbench/datasets/figure_ground_convexity.py +154 -0
- mlvbench-1.0.0/mlvbench/datasets/figure_ground_surroundedness.py +110 -0
- mlvbench-1.0.0/mlvbench/datasets/figure_ground_symmetry.py +274 -0
- mlvbench-1.0.0/mlvbench/datasets/msra10k.py +195 -0
- mlvbench-1.0.0/mlvbench/download.py +203 -0
- mlvbench-1.0.0/mlvbench/infrastructure.py +136 -0
- mlvbench-1.0.0/mlvbench/models/__init__.py +230 -0
- mlvbench-1.0.0/mlvbench/models/__main__.py +76 -0
- mlvbench-1.0.0/mlvbench/models/_base.py +544 -0
- mlvbench-1.0.0/mlvbench/models/_bundles.py +62 -0
- mlvbench-1.0.0/mlvbench/models/diffusers.py +231 -0
- mlvbench-1.0.0/mlvbench/models/franca.py +245 -0
- mlvbench-1.0.0/mlvbench/models/timm.py +534 -0
- mlvbench-1.0.0/mlvbench/models/webssl.py +188 -0
- mlvbench-1.0.0/mlvbench/monitoring.py +174 -0
- mlvbench-1.0.0/mlvbench/probes.py +227 -0
- mlvbench-1.0.0/mlvbench/stimuli/__init__.py +1 -0
- mlvbench-1.0.0/mlvbench/stimuli/shapes.py +238 -0
- mlvbench-1.0.0/mlvbench/stimuli/textures.py +155 -0
- mlvbench-1.0.0/mlvbench/stimuli/transforms.py +146 -0
- mlvbench-1.0.0/mlvbench/tasks/__init__.py +34 -0
- mlvbench-1.0.0/mlvbench/tasks/_base.py +136 -0
- mlvbench-1.0.0/mlvbench/tasks/binary_segmentation.py +268 -0
- mlvbench-1.0.0/mlvbench/trainer.py +657 -0
- mlvbench-1.0.0/pyproject.toml +83 -0
- mlvbench-1.0.0/tests/conftest.py +30 -0
- mlvbench-1.0.0/tests/datasets/test_figure_ground_symmetry.py +98 -0
- mlvbench-1.0.0/tests/models/test_all.py +308 -0
- mlvbench-1.0.0/tests/models/test_base.py +228 -0
- mlvbench-1.0.0/tests/models/test_diffusers.py +36 -0
- mlvbench-1.0.0/tests/models/test_random_init.py +122 -0
- mlvbench-1.0.0/tests/models/test_timm.py +41 -0
- mlvbench-1.0.0/tests/stimuli/test_shapes.py +119 -0
- mlvbench-1.0.0/tests/stimuli/test_textures.py +160 -0
- mlvbench-1.0.0/tests/tasks/test_binary_segmentation.py +220 -0
- mlvbench-1.0.0/tests/test_cache.py +266 -0
- mlvbench-1.0.0/tests/test_infrastructure.py +95 -0
- mlvbench-1.0.0/tests/test_mlvbench.py +6 -0
- mlvbench-1.0.0/tests/test_monitoring.py +111 -0
- mlvbench-1.0.0/tests/test_probes.py +97 -0
- mlvbench-1.0.0/uv.lock +3299 -0
- mlvbench-1.0.0/zensical.toml +368 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
*
|
|
@@ -0,0 +1,247 @@
|
|
|
1
|
+
{
|
|
2
|
+
"data": {
|
|
3
|
+
"meta": {},
|
|
4
|
+
"content": "<h1 id=\"mlvbenchprobes\"><code>mlvbench.probes</code><a class=\"headerlink\" href=\"#mlvbenchprobes\" title=\"Permanent link\">¶</a></h1>\n\n\n<div class=\"doc doc-object doc-module\">\n\n\n\n<a id=\"mlvbench.probes\"></a>\n <div class=\"doc doc-contents first\">\n\n <p>Probes.</p>\n<p>Probes are small models that readout information from intermediate features of a\npretrained vision model.</p>\n\n\n\n\n\n\n\n\n\n\n<div class=\"doc doc-children\">\n\n\n\n\n\n\n\n\n\n<div class=\"doc doc-object doc-class\">\n\n\n\n<h2 id=\"mlvbench.probes.LinearProbe\" class=\"doc doc-heading\">\n <code>LinearProbe</code>\n\n\n<a href=\"#mlvbench.probes.LinearProbe\" class=\"headerlink\" title=\"Permanent link\">¶</a></h2>\n\n\n <div class=\"doc doc-contents \">\n <p class=\"doc doc-class-bases\">\n Bases: <code><autoref identifier=\"mlvbench.probes.Probe\" backlink-type=\"subclassed-by\" backlink-anchor=\"mlvbench.probes.LinearProbe\" optional hover>Probe</autoref></code></p>\n\n\n\n <p>Linear probe.</p>\n<p>A linear projection of the input features to a scalar, optionally with a learnable\nbias:</p>\n<div class=\"arithmatex\">\\[\n y = W x + b\n\\]</div>\n\n\n\n\n\n\n\n\n\n\n\n<div class=\"doc doc-children\">\n\n\n\n\n\n\n\n<div class=\"doc doc-object doc-attribute\">\n\n\n\n<h3 id=\"mlvbench.probes.LinearProbe.name\" class=\"doc doc-heading\">\n <code class=\"highlight language-python\"><span class=\"n\">name</span></code>\n\n <span class=\"doc doc-labels\">\n <small class=\"doc doc-label doc-label-property\"><code>property</code></small>\n </span>\n\n<a href=\"#mlvbench.probes.LinearProbe.name\" class=\"headerlink\" title=\"Permanent link\">¶</a></h3>\n\n\n <div class=\"doc doc-contents \">\n\n <p>Name of the probe type (<code>\"linear\"</code>).</p>\n\n </div>\n\n</div>\n\n\n\n\n<div class=\"doc doc-object doc-function\">\n\n\n<h3 id=\"mlvbench.probes.LinearProbe.__init__\" class=\"doc doc-heading\">\n <code class=\"highlight language-python\"><span class=\"fm\">__init__</span><span class=\"p\">(</span><span class=\"n\">layer</span><span class=\"p\">,</span> <span class=\"n\">input_dim</span><span class=\"p\">,</span> <span class=\"n\">bias</span><span class=\"o\">=</span><span class=\"s1\">'scalar'</span><span class=\"p\">,</span> <span class=\"n\">num_patches</span><span class=\"o\">=</span><span class=\"kc\">None</span><span class=\"p\">,</span> <span class=\"n\">metadata</span><span class=\"o\">=</span><span class=\"kc\">None</span><span class=\"p\">)</span></code>\n\n<a href=\"#mlvbench.probes.LinearProbe.__init__\" class=\"headerlink\" title=\"Permanent link\">¶</a></h3>\n\n\n <div class=\"doc doc-contents \">\n\n <p>Initialize the probe.</p>\n\n\n<p><span class=\"doc-section-title\">Parameters:</span></p>\n <table>\n <thead>\n <tr>\n <th>Name</th>\n <th>Type</th>\n <th>Description</th>\n <th>Default</th>\n </tr>\n </thead>\n <tbody>\n <tr class=\"doc-section-item\">\n <td>\n <code>layer</code>\n </td>\n <td>\n <code><autoref identifier=\"str\" backlink-type=\"used-by\" backlink-anchor=\"mlvbench.probes.LinearProbe.__init__\" optional>str</autoref></code>\n </td>\n <td>\n <div class=\"doc-md-description\">\n <p>Name of the model layer the probe reads from.</p>\n </div>\n </td>\n <td>\n <em>required</em>\n </td>\n </tr>\n <tr class=\"doc-section-item\">\n <td>\n <code>input_dim</code>\n </td>\n <td>\n <code><autoref identifier=\"int\" backlink-type=\"used-by\" backlink-anchor=\"mlvbench.probes.LinearProbe.__init__\" optional>int</autoref></code>\n </td>\n <td>\n <div class=\"doc-md-description\">\n <p>Number of dimensions of the input features.</p>\n </div>\n </td>\n <td>\n <em>required</em>\n </td>\n </tr>\n <tr class=\"doc-section-item\">\n <td>\n <code>bias</code>\n </td>\n <td>\n <code><autoref identifier=\"typing.Literal\" backlink-type=\"used-by\" backlink-anchor=\"mlvbench.probes.LinearProbe.__init__\" optional hover>Literal</autoref>['none', 'scalar', 'spatial'] | <autoref identifier=\"torch.Tensor\" backlink-type=\"used-by\" backlink-anchor=\"mlvbench.probes.LinearProbe.__init__\" optional hover>Tensor</autoref></code>\n </td>\n <td>\n <div class=\"doc-md-description\">\n <p>The kind of learnable bias added to the output:</p>\n<ul>\n<li><code>\"none\"</code>: no bias.</li>\n<li><code>\"scalar\"</code>: a single learnable scalar shared across all patches.</li>\n<li><code>\"spatial\"</code>: a learnable per-patch bias with shape <code>(num_patches, 1)</code>,\n initialized to zero. Requires <code>num_patches</code>.</li>\n<li>a <code>torch.Tensor</code> (a prior with shape <code>(N, 1)</code>): a per-patch bias\n initialized from the tensor; equivalent to <code>\"spatial\"</code> with\n <code>num_patches = N</code>.</li>\n</ul>\n </div>\n </td>\n <td>\n <code>'scalar'</code>\n </td>\n </tr>\n <tr class=\"doc-section-item\">\n <td>\n <code>num_patches</code>\n </td>\n <td>\n <code><autoref identifier=\"int\" backlink-type=\"used-by\" backlink-anchor=\"mlvbench.probes.LinearProbe.__init__\" optional>int</autoref> | None</code>\n </td>\n <td>\n <div class=\"doc-md-description\">\n <p>Number of patch tokens of the input features. Required when\nusing a <code>\"spatial\"</code> bias and ignored otherwise.</p>\n </div>\n </td>\n <td>\n <code>None</code>\n </td>\n </tr>\n <tr class=\"doc-section-item\">\n <td>\n <code>metadata</code>\n </td>\n <td>\n <code><autoref identifier=\"dict\" backlink-type=\"used-by\" backlink-anchor=\"mlvbench.probes.LinearProbe.__init__\" optional>dict</autoref>[<autoref identifier=\"str\" backlink-type=\"used-by\" backlink-anchor=\"mlvbench.probes.LinearProbe.__init__\" optional>str</autoref>, <autoref identifier=\"typing.Any\" backlink-type=\"used-by\" backlink-anchor=\"mlvbench.probes.LinearProbe.__init__\" optional hover>Any</autoref>] | None</code>\n </td>\n <td>\n <div class=\"doc-md-description\">\n <p>Free-form metadata to attach to the probe.</p>\n </div>\n </td>\n <td>\n <code>None</code>\n </td>\n </tr>\n </tbody>\n </table>\n\n\n </div>\n\n</div>\n\n<div class=\"doc doc-object doc-function\">\n\n\n<h3 id=\"mlvbench.probes.LinearProbe.forward\" class=\"doc doc-heading\">\n <code class=\"highlight language-python\"><span class=\"n\">forward</span><span class=\"p\">(</span><span class=\"n\">features</span><span class=\"p\">)</span></code>\n\n<a href=\"#mlvbench.probes.LinearProbe.forward\" class=\"headerlink\" title=\"Permanent link\">¶</a></h3>\n\n\n <div class=\"doc doc-contents \">\n\n <p>Forward pass.</p>\n\n\n<p><span class=\"doc-section-title\">Parameters:</span></p>\n <table>\n <thead>\n <tr>\n <th>Name</th>\n <th>Type</th>\n <th>Description</th>\n <th>Default</th>\n </tr>\n </thead>\n <tbody>\n <tr class=\"doc-section-item\">\n <td>\n <code>features</code>\n </td>\n <td>\n <code><autoref identifier=\"mlvbench.models.Features\" backlink-type=\"used-by\" backlink-anchor=\"mlvbench.probes.LinearProbe.forward\" optional hover>Features</autoref></code>\n </td>\n <td>\n <div class=\"doc-md-description\">\n <p>The features extracted from the model. The probe uses the patch\ntokens of <code>self.layer</code>, expecting shape <code>(B, N, C)</code> and dtype <code>float32</code>.</p>\n </div>\n </td>\n <td>\n <em>required</em>\n </td>\n </tr>\n </tbody>\n </table>\n\n\n <p><span class=\"doc-section-title\">Returns:</span></p>\n <table>\n <thead>\n <tr>\n <th>Type</th>\n <th>Description</th>\n </tr>\n </thead>\n <tbody>\n <tr class=\"doc-section-item\">\n <td>\n <code><autoref identifier=\"torch.Tensor\" backlink-type=\"returned-by\" backlink-anchor=\"mlvbench.probes.LinearProbe.forward\" optional hover>Tensor</autoref></code>\n </td>\n <td>\n <div class=\"doc-md-description\">\n <p>The output with shape <code>(B, N, 1)</code> and dtype <code>float32</code>.</p>\n </div>\n </td>\n </tr>\n </tbody>\n </table>\n\n\n </div>\n\n</div>\n\n<div class=\"doc doc-object doc-function\">\n\n\n<h3 id=\"mlvbench.probes.LinearProbe.select_features\" class=\"doc doc-heading\">\n <code class=\"highlight language-python\"><span class=\"n\">select_features</span><span class=\"p\">(</span><span class=\"n\">features</span><span class=\"p\">)</span></code>\n\n<a href=\"#mlvbench.probes.LinearProbe.select_features\" class=\"headerlink\" title=\"Permanent link\">¶</a></h3>\n\n\n <div class=\"doc doc-contents \">\n\n <p>Select the part of the feature representation used by the probe.</p>\n<p>Defaults to the patch tokens of <code>self.layer</code> with shape <code>(B, N, C)</code>. Override to\nread from a different part of the representation (e.g. the cls token or a\ndifferent token format).</p>\n\n\n<p><span class=\"doc-section-title\">Parameters:</span></p>\n <table>\n <thead>\n <tr>\n <th>Name</th>\n <th>Type</th>\n <th>Description</th>\n <th>Default</th>\n </tr>\n </thead>\n <tbody>\n <tr class=\"doc-section-item\">\n <td>\n <code>features</code>\n </td>\n <td>\n <code><autoref identifier=\"mlvbench.models.Features\" backlink-type=\"used-by\" backlink-anchor=\"mlvbench.probes.LinearProbe.select_features\" optional hover>Features</autoref></code>\n </td>\n <td>\n <div class=\"doc-md-description\">\n <p>The features extracted from the backbone.</p>\n </div>\n </td>\n <td>\n <em>required</em>\n </td>\n </tr>\n </tbody>\n </table>\n\n\n <p><span class=\"doc-section-title\">Returns:</span></p>\n <table>\n <thead>\n <tr>\n <th>Type</th>\n <th>Description</th>\n </tr>\n </thead>\n <tbody>\n <tr class=\"doc-section-item\">\n <td>\n <code><autoref identifier=\"torch.Tensor\" backlink-type=\"returned-by\" backlink-anchor=\"mlvbench.probes.LinearProbe.select_features\" optional hover>Tensor</autoref></code>\n </td>\n <td>\n <div class=\"doc-md-description\">\n <p>The selected feature tensor.</p>\n </div>\n </td>\n </tr>\n </tbody>\n </table>\n\n\n </div>\n\n</div>\n\n<div class=\"doc doc-object doc-function\">\n\n\n<h3 id=\"mlvbench.probes.LinearProbe.serialize\" class=\"doc doc-heading\">\n <code class=\"highlight language-python\"><span class=\"n\">serialize</span><span class=\"p\">()</span></code>\n\n<a href=\"#mlvbench.probes.LinearProbe.serialize\" class=\"headerlink\" title=\"Permanent link\">¶</a></h3>\n\n\n <div class=\"doc doc-contents \">\n\n <p>Serialize the probe.</p>\n<p>See <autoref identifier=\"mlvbench.probes.Probe.serialize\"><code>Probe.serialize</code></autoref>.</p>\n\n\n </div>\n\n</div>\n\n\n\n </div>\n\n </div>\n\n</div>\n\n<div class=\"doc doc-object doc-class\">\n\n\n\n<h2 id=\"mlvbench.probes.Probe\" class=\"doc doc-heading\">\n <code>Probe</code>\n\n\n<a href=\"#mlvbench.probes.Probe\" class=\"headerlink\" title=\"Permanent link\">¶</a></h2>\n\n\n <div class=\"doc doc-contents \">\n <p class=\"doc doc-class-bases\">\n Bases: <code><autoref identifier=\"torch.nn.Module\" backlink-type=\"subclassed-by\" backlink-anchor=\"mlvbench.probes.Probe\" optional hover>Module</autoref></code>, <code><autoref identifier=\"abc.ABC\" backlink-type=\"subclassed-by\" backlink-anchor=\"mlvbench.probes.Probe\" optional hover>ABC</autoref></code></p>\n\n\n\n <p>Abstract base class for probes.</p>\n\n\n<p><span class=\"doc-section-title\">Attributes:</span></p>\n <table>\n <thead>\n <tr>\n <th>Name</th>\n <th>Type</th>\n <th>Description</th>\n </tr>\n </thead>\n <tbody>\n <tr class=\"doc-section-item\">\n <td><code><autoref identifier=\"mlvbench.probes.Probe.name\" optional hover>name</autoref></code></td>\n <td>\n <code><autoref identifier=\"str\" optional>str</autoref></code>\n </td>\n <td>\n <div class=\"doc-md-description\">\n <p>Name of the probe type.</p>\n </div>\n </td>\n </tr>\n <tr class=\"doc-section-item\">\n <td><code><autoref identifier=\"mlvbench.probes.Probe.layer\" optional hover>layer</autoref></code></td>\n <td>\n <code><autoref identifier=\"str\" optional>str</autoref></code>\n </td>\n <td>\n <div class=\"doc-md-description\">\n <p>Name of the backbone layer the probe reads from.</p>\n </div>\n </td>\n </tr>\n <tr class=\"doc-section-item\">\n <td><code><autoref identifier=\"mlvbench.probes.Probe.metadata\" optional hover>metadata</autoref></code></td>\n <td>\n <code><autoref identifier=\"dict\" optional>dict</autoref>[<autoref identifier=\"str\" optional>str</autoref>, <autoref identifier=\"typing.Any\" optional hover>Any</autoref>]</code>\n </td>\n <td>\n <div class=\"doc-md-description\">\n <p>Free-form dict of training/experiment information attached to the\nprobe. Persisted in full when the probe is saved.</p>\n </div>\n </td>\n </tr>\n </tbody>\n </table>\n\n\n\n\n\n\n\n\n\n\n\n<div class=\"doc doc-children\">\n\n\n\n\n\n\n\n<div class=\"doc doc-object doc-attribute\">\n\n\n\n<h3 id=\"mlvbench.probes.Probe.name\" class=\"doc doc-heading\">\n <code class=\"highlight language-python\"><span class=\"n\">name</span></code>\n\n <span class=\"doc doc-labels\">\n <small class=\"doc doc-label doc-label-abstractmethod\"><code>abstractmethod</code></small>\n <small class=\"doc doc-label doc-label-property\"><code>property</code></small>\n </span>\n\n<a href=\"#mlvbench.probes.Probe.name\" class=\"headerlink\" title=\"Permanent link\">¶</a></h3>\n\n\n <div class=\"doc doc-contents \">\n\n <p>Name of the probe type.</p>\n\n </div>\n\n</div>\n\n\n\n\n<div class=\"doc doc-object doc-function\">\n\n\n<h3 id=\"mlvbench.probes.Probe.__init__\" class=\"doc doc-heading\">\n <code class=\"highlight language-python\"><span class=\"fm\">__init__</span><span class=\"p\">(</span><span class=\"n\">layer</span><span class=\"p\">,</span> <span class=\"n\">input_dim</span><span class=\"p\">,</span> <span class=\"o\">*</span><span class=\"p\">,</span> <span class=\"n\">metadata</span><span class=\"o\">=</span><span class=\"kc\">None</span><span class=\"p\">)</span></code>\n\n<a href=\"#mlvbench.probes.Probe.__init__\" class=\"headerlink\" title=\"Permanent link\">¶</a></h3>\n\n\n <div class=\"doc doc-contents \">\n\n <p>Initialize the probe.</p>\n\n\n<p><span class=\"doc-section-title\">Parameters:</span></p>\n <table>\n <thead>\n <tr>\n <th>Name</th>\n <th>Type</th>\n <th>Description</th>\n <th>Default</th>\n </tr>\n </thead>\n <tbody>\n <tr class=\"doc-section-item\">\n <td>\n <code>layer</code>\n </td>\n <td>\n <code><autoref identifier=\"str\" backlink-type=\"used-by\" backlink-anchor=\"mlvbench.probes.Probe.__init__\" optional>str</autoref></code>\n </td>\n <td>\n <div class=\"doc-md-description\">\n <p>Name of the model layer the probe reads from.</p>\n </div>\n </td>\n <td>\n <em>required</em>\n </td>\n </tr>\n <tr class=\"doc-section-item\">\n <td>\n <code>input_dim</code>\n </td>\n <td>\n <code><autoref identifier=\"int\" backlink-type=\"used-by\" backlink-anchor=\"mlvbench.probes.Probe.__init__\" optional>int</autoref></code>\n </td>\n <td>\n <div class=\"doc-md-description\">\n <p>Number of dimensions of the input features.</p>\n </div>\n </td>\n <td>\n <em>required</em>\n </td>\n </tr>\n <tr class=\"doc-section-item\">\n <td>\n <code>metadata</code>\n </td>\n <td>\n <code><autoref identifier=\"dict\" backlink-type=\"used-by\" backlink-anchor=\"mlvbench.probes.Probe.__init__\" optional>dict</autoref>[<autoref identifier=\"str\" backlink-type=\"used-by\" backlink-anchor=\"mlvbench.probes.Probe.__init__\" optional>str</autoref>, <autoref identifier=\"typing.Any\" backlink-type=\"used-by\" backlink-anchor=\"mlvbench.probes.Probe.__init__\" optional hover>Any</autoref>] | None</code>\n </td>\n <td>\n <div class=\"doc-md-description\">\n <p>Free-form dict of training/experiment information.</p>\n </div>\n </td>\n <td>\n <code>None</code>\n </td>\n </tr>\n </tbody>\n </table>\n\n\n </div>\n\n</div>\n\n<div class=\"doc doc-object doc-function\">\n\n\n<h3 id=\"mlvbench.probes.Probe.forward\" class=\"doc doc-heading\">\n <code class=\"highlight language-python\"><span class=\"n\">forward</span><span class=\"p\">(</span><span class=\"n\">features</span><span class=\"p\">)</span></code>\n\n <span class=\"doc doc-labels\">\n <small class=\"doc doc-label doc-label-abstractmethod\"><code>abstractmethod</code></small>\n </span>\n\n<a href=\"#mlvbench.probes.Probe.forward\" class=\"headerlink\" title=\"Permanent link\">¶</a></h3>\n\n\n <div class=\"doc doc-contents \">\n\n <p>Apply the probe to the given features.</p>\n<p>The probe selects the part of the representation it reads from via\n<autoref identifier=\"mlvbench.probes.Probe.select_features\"><code>select_features</code></autoref>.</p>\n\n\n<p><span class=\"doc-section-title\">Parameters:</span></p>\n <table>\n <thead>\n <tr>\n <th>Name</th>\n <th>Type</th>\n <th>Description</th>\n <th>Default</th>\n </tr>\n </thead>\n <tbody>\n <tr class=\"doc-section-item\">\n <td>\n <code>features</code>\n </td>\n <td>\n <code><autoref identifier=\"mlvbench.models.Features\" backlink-type=\"used-by\" backlink-anchor=\"mlvbench.probes.Probe.forward\" optional hover>Features</autoref></code>\n </td>\n <td>\n <div class=\"doc-md-description\">\n <p>The features extracted from the backbone.</p>\n </div>\n </td>\n <td>\n <em>required</em>\n </td>\n </tr>\n </tbody>\n </table>\n\n\n <p><span class=\"doc-section-title\">Returns:</span></p>\n <table>\n <thead>\n <tr>\n <th>Type</th>\n <th>Description</th>\n </tr>\n </thead>\n <tbody>\n <tr class=\"doc-section-item\">\n <td>\n <code><autoref identifier=\"torch.Tensor\" backlink-type=\"returned-by\" backlink-anchor=\"mlvbench.probes.Probe.forward\" optional hover>Tensor</autoref></code>\n </td>\n <td>\n <div class=\"doc-md-description\">\n <p>The prediction from the probe as torch.Tensor. Shape and dtype very per\nprobe.</p>\n </div>\n </td>\n </tr>\n </tbody>\n </table>\n\n\n </div>\n\n</div>\n\n<div class=\"doc doc-object doc-function\">\n\n\n<h3 id=\"mlvbench.probes.Probe.select_features\" class=\"doc doc-heading\">\n <code class=\"highlight language-python\"><span class=\"n\">select_features</span><span class=\"p\">(</span><span class=\"n\">features</span><span class=\"p\">)</span></code>\n\n<a href=\"#mlvbench.probes.Probe.select_features\" class=\"headerlink\" title=\"Permanent link\">¶</a></h3>\n\n\n <div class=\"doc doc-contents \">\n\n <p>Select the part of the feature representation used by the probe.</p>\n<p>Defaults to the patch tokens of <code>self.layer</code> with shape <code>(B, N, C)</code>. Override to\nread from a different part of the representation (e.g. the cls token or a\ndifferent token format).</p>\n\n\n<p><span class=\"doc-section-title\">Parameters:</span></p>\n <table>\n <thead>\n <tr>\n <th>Name</th>\n <th>Type</th>\n <th>Description</th>\n <th>Default</th>\n </tr>\n </thead>\n <tbody>\n <tr class=\"doc-section-item\">\n <td>\n <code>features</code>\n </td>\n <td>\n <code><autoref identifier=\"mlvbench.models.Features\" backlink-type=\"used-by\" backlink-anchor=\"mlvbench.probes.Probe.select_features\" optional hover>Features</autoref></code>\n </td>\n <td>\n <div class=\"doc-md-description\">\n <p>The features extracted from the backbone.</p>\n </div>\n </td>\n <td>\n <em>required</em>\n </td>\n </tr>\n </tbody>\n </table>\n\n\n <p><span class=\"doc-section-title\">Returns:</span></p>\n <table>\n <thead>\n <tr>\n <th>Type</th>\n <th>Description</th>\n </tr>\n </thead>\n <tbody>\n <tr class=\"doc-section-item\">\n <td>\n <code><autoref identifier=\"torch.Tensor\" backlink-type=\"returned-by\" backlink-anchor=\"mlvbench.probes.Probe.select_features\" optional hover>Tensor</autoref></code>\n </td>\n <td>\n <div class=\"doc-md-description\">\n <p>The selected feature tensor.</p>\n </div>\n </td>\n </tr>\n </tbody>\n </table>\n\n\n </div>\n\n</div>\n\n<div class=\"doc doc-object doc-function\">\n\n\n<h3 id=\"mlvbench.probes.Probe.serialize\" class=\"doc doc-heading\">\n <code class=\"highlight language-python\"><span class=\"n\">serialize</span><span class=\"p\">()</span></code>\n\n <span class=\"doc doc-labels\">\n <small class=\"doc doc-label doc-label-abstractmethod\"><code>abstractmethod</code></small>\n </span>\n\n<a href=\"#mlvbench.probes.Probe.serialize\" class=\"headerlink\" title=\"Permanent link\">¶</a></h3>\n\n\n <div class=\"doc doc-contents \">\n\n <p>Return all information needed to reconstruct the probe.</p>\n<p>This returns a self-describing dictionary that includes both the torch\n<code>state_dict</code> and all config options. The probe can be rebuilt from this\nrepresentation via <autoref identifier=\"mlvbench.probes.build_probe\"><code>build_probe</code></autoref>.</p>\n\n\n <p><span class=\"doc-section-title\">Returns:</span></p>\n <table>\n <thead>\n <tr>\n <th>Type</th>\n <th>Description</th>\n </tr>\n </thead>\n <tbody>\n <tr class=\"doc-section-item\">\n <td>\n <code><autoref identifier=\"dict\" backlink-type=\"returned-by\" backlink-anchor=\"mlvbench.probes.Probe.serialize\" optional>dict</autoref>[<autoref identifier=\"str\" backlink-type=\"returned-by\" backlink-anchor=\"mlvbench.probes.Probe.serialize\" optional>str</autoref>, <autoref identifier=\"typing.Any\" backlink-type=\"returned-by\" backlink-anchor=\"mlvbench.probes.Probe.serialize\" optional hover>Any</autoref>]</code>\n </td>\n <td>\n <div class=\"doc-md-description\">\n <p>A dictionary describing the probe, with detached CPU tensors for <code>weights</code>.</p>\n </div>\n </td>\n </tr>\n </tbody>\n </table>\n\n\n </div>\n\n</div>\n\n\n\n </div>\n\n </div>\n\n</div>\n\n\n<div class=\"doc doc-object doc-function\">\n\n\n<h2 id=\"mlvbench.probes.build_probe\" class=\"doc doc-heading\">\n <code class=\"highlight language-python\"><span class=\"n\">build_probe</span><span class=\"p\">(</span><span class=\"n\">name</span><span class=\"p\">,</span> <span class=\"n\">layer</span><span class=\"p\">,</span> <span class=\"n\">input_dim</span><span class=\"p\">,</span> <span class=\"n\">metadata</span><span class=\"o\">=</span><span class=\"kc\">None</span><span class=\"p\">,</span> <span class=\"n\">state_dict</span><span class=\"o\">=</span><span class=\"kc\">None</span><span class=\"p\">,</span> <span class=\"n\">probe_types</span><span class=\"o\">=</span><span class=\"kc\">None</span><span class=\"p\">,</span> <span class=\"o\">**</span><span class=\"n\">kwargs</span><span class=\"p\">)</span></code>\n\n<a href=\"#mlvbench.probes.build_probe\" class=\"headerlink\" title=\"Permanent link\">¶</a></h2>\n\n\n <div class=\"doc doc-contents \">\n\n <p>Build the probe with the given name and arguments.</p>\n\n\n<p><span class=\"doc-section-title\">Parameters:</span></p>\n <table>\n <thead>\n <tr>\n <th>Name</th>\n <th>Type</th>\n <th>Description</th>\n <th>Default</th>\n </tr>\n </thead>\n <tbody>\n <tr class=\"doc-section-item\">\n <td>\n <code>name</code>\n </td>\n <td>\n <code><autoref identifier=\"str\" backlink-type=\"used-by\" backlink-anchor=\"mlvbench.probes.build_probe\" optional>str</autoref></code>\n </td>\n <td>\n <div class=\"doc-md-description\">\n <p>Name of the probe type (e.g. <code>\"linear\"</code>).</p>\n </div>\n </td>\n <td>\n <em>required</em>\n </td>\n </tr>\n <tr class=\"doc-section-item\">\n <td>\n <code>layer</code>\n </td>\n <td>\n <code><autoref identifier=\"str\" backlink-type=\"used-by\" backlink-anchor=\"mlvbench.probes.build_probe\" optional>str</autoref></code>\n </td>\n <td>\n <div class=\"doc-md-description\">\n <p>Name of the model layer the probe reads from.</p>\n </div>\n </td>\n <td>\n <em>required</em>\n </td>\n </tr>\n <tr class=\"doc-section-item\">\n <td>\n <code>input_dim</code>\n </td>\n <td>\n <code><autoref identifier=\"int\" backlink-type=\"used-by\" backlink-anchor=\"mlvbench.probes.build_probe\" optional>int</autoref></code>\n </td>\n <td>\n <div class=\"doc-md-description\">\n <p>Number of dimensions of the input features.</p>\n </div>\n </td>\n <td>\n <em>required</em>\n </td>\n </tr>\n <tr class=\"doc-section-item\">\n <td>\n <code>metadata</code>\n </td>\n <td>\n <code><autoref identifier=\"dict\" backlink-type=\"used-by\" backlink-anchor=\"mlvbench.probes.build_probe\" optional>dict</autoref>[<autoref identifier=\"str\" backlink-type=\"used-by\" backlink-anchor=\"mlvbench.probes.build_probe\" optional>str</autoref>, <autoref identifier=\"typing.Any\" backlink-type=\"used-by\" backlink-anchor=\"mlvbench.probes.build_probe\" optional hover>Any</autoref>] | None</code>\n </td>\n <td>\n <div class=\"doc-md-description\">\n <p>Free-form metadata to attach to the probe.</p>\n </div>\n </td>\n <td>\n <code>None</code>\n </td>\n </tr>\n <tr class=\"doc-section-item\">\n <td>\n <code>state_dict</code>\n </td>\n <td>\n <code><autoref identifier=\"dict\" backlink-type=\"used-by\" backlink-anchor=\"mlvbench.probes.build_probe\" optional>dict</autoref>[<autoref identifier=\"str\" backlink-type=\"used-by\" backlink-anchor=\"mlvbench.probes.build_probe\" optional>str</autoref>, <autoref identifier=\"typing.Any\" backlink-type=\"used-by\" backlink-anchor=\"mlvbench.probes.build_probe\" optional hover>Any</autoref>] | None</code>\n </td>\n <td>\n <div class=\"doc-md-description\">\n <p>Optional state dict for restoring pretrained probes.</p>\n </div>\n </td>\n <td>\n <code>None</code>\n </td>\n </tr>\n <tr class=\"doc-section-item\">\n <td>\n <code>probe_types</code>\n </td>\n <td>\n <code><autoref identifier=\"dict\" backlink-type=\"used-by\" backlink-anchor=\"mlvbench.probes.build_probe\" optional>dict</autoref>[<autoref identifier=\"str\" backlink-type=\"used-by\" backlink-anchor=\"mlvbench.probes.build_probe\" optional>str</autoref>, <autoref identifier=\"type\" backlink-type=\"used-by\" backlink-anchor=\"mlvbench.probes.build_probe\" optional>type</autoref>[<autoref identifier=\"mlvbench.probes.Probe\" backlink-type=\"used-by\" backlink-anchor=\"mlvbench.probes.build_probe\" optional hover>Probe</autoref>]] | None</code>\n </td>\n <td>\n <div class=\"doc-md-description\">\n <p>Optional mapping of custom probe type names to <code>Probe</code> subclasses,\nmerged with the built-in types. Each class must be constructible as\n<code>Cls(layer, input_dim, metadata=metadata, **kwargs)</code>.</p>\n </div>\n </td>\n <td>\n <code>None</code>\n </td>\n </tr>\n <tr class=\"doc-section-item\">\n <td>\n <code>**kwargs</code>\n </td>\n <td>\n <code><autoref identifier=\"typing.Any\" backlink-type=\"used-by\" backlink-anchor=\"mlvbench.probes.build_probe\" optional hover>Any</autoref></code>\n </td>\n <td>\n <div class=\"doc-md-description\">\n <p>Additional keyword arguments forwarded to the probe constructor (e.g.\n<code>bias</code> and <code>num_patches</code>).</p>\n </div>\n </td>\n <td>\n <code>{}</code>\n </td>\n </tr>\n </tbody>\n </table>\n\n\n<p><span class=\"doc-section-title\">Raises:</span></p>\n <table>\n <thead>\n <tr>\n <th>Type</th>\n <th>Description</th>\n </tr>\n </thead>\n <tbody>\n <tr class=\"doc-section-item\">\n <td>\n <code><autoref identifier=\"ValueError\" backlink-type=\"raised-by\" backlink-anchor=\"mlvbench.probes.build_probe\" optional>ValueError</autoref></code>\n </td>\n <td>\n <div class=\"doc-md-description\">\n <p>If <code>name</code> is not a known built-in or custom probe type.</p>\n </div>\n </td>\n </tr>\n </tbody>\n </table>\n\n\n </div>\n\n</div>\n\n\n\n </div>\n\n </div>\n\n</div>",
|
|
5
|
+
"search": [
|
|
6
|
+
{
|
|
7
|
+
"location": null,
|
|
8
|
+
"level": 1,
|
|
9
|
+
"title": "<code>mlvbench.probes</code>",
|
|
10
|
+
"text": "<p>Probes.</p> <p>Probes are small models that readout information from intermediate features of a pretrained vision model.</p>",
|
|
11
|
+
"path": [],
|
|
12
|
+
"tags": []
|
|
13
|
+
},
|
|
14
|
+
{
|
|
15
|
+
"location": "mlvbench.probes.LinearProbe",
|
|
16
|
+
"level": 2,
|
|
17
|
+
"title": "<code>LinearProbe</code>",
|
|
18
|
+
"text": "<p> Bases: <code>Probe</code></p> <p>Linear probe.</p> <p>A linear projection of the input features to a scalar, optionally with a learnable bias:</p> \\[ y = W x + b \\]",
|
|
19
|
+
"path": [],
|
|
20
|
+
"tags": []
|
|
21
|
+
},
|
|
22
|
+
{
|
|
23
|
+
"location": "mlvbench.probes.LinearProbe.name",
|
|
24
|
+
"level": 3,
|
|
25
|
+
"title": "<code>name</code> <code>property</code>",
|
|
26
|
+
"text": "<p>Name of the probe type (<code>\"linear\"</code>).</p>",
|
|
27
|
+
"path": [],
|
|
28
|
+
"tags": []
|
|
29
|
+
},
|
|
30
|
+
{
|
|
31
|
+
"location": "mlvbench.probes.LinearProbe.__init__",
|
|
32
|
+
"level": 3,
|
|
33
|
+
"title": "<code>__init__(layer, input_dim, bias='scalar', num_patches=None, metadata=None)</code>",
|
|
34
|
+
"text": "<p>Initialize the probe.</p> <p>Parameters:</p> Name Type Description Default <code>layer</code> <code>str</code> <p>Name of the model layer the probe reads from.</p> required <code>input_dim</code> <code>int</code> <p>Number of dimensions of the input features.</p> required <code>bias</code> <code>Literal['none', 'scalar', 'spatial'] | Tensor</code> <p>The kind of learnable bias added to the output:</p> <ul> <li><code>\"none\"</code>: no bias.</li> <li><code>\"scalar\"</code>: a single learnable scalar shared across all patches.</li> <li><code>\"spatial\"</code>: a learnable per-patch bias with shape <code>(num_patches, 1)</code>, initialized to zero. Requires <code>num_patches</code>.</li> <li>a <code>torch.Tensor</code> (a prior with shape <code>(N, 1)</code>): a per-patch bias initialized from the tensor; equivalent to <code>\"spatial\"</code> with <code>num_patches = N</code>.</li> </ul> <code>'scalar'</code> <code>num_patches</code> <code>int | None</code> <p>Number of patch tokens of the input features. Required when using a <code>\"spatial\"</code> bias and ignored otherwise.</p> <code>None</code> <code>metadata</code> <code>dict[str, Any] | None</code> <p>Free-form metadata to attach to the probe.</p> <code>None</code>",
|
|
35
|
+
"path": [],
|
|
36
|
+
"tags": []
|
|
37
|
+
},
|
|
38
|
+
{
|
|
39
|
+
"location": "mlvbench.probes.LinearProbe.forward",
|
|
40
|
+
"level": 3,
|
|
41
|
+
"title": "<code>forward(features)</code>",
|
|
42
|
+
"text": "<p>Forward pass.</p> <p>Parameters:</p> Name Type Description Default <code>features</code> <code>Features</code> <p>The features extracted from the model. The probe uses the patch tokens of <code>self.layer</code>, expecting shape <code>(B, N, C)</code> and dtype <code>float32</code>.</p> required <p>Returns:</p> Type Description <code>Tensor</code> <p>The output with shape <code>(B, N, 1)</code> and dtype <code>float32</code>.</p>",
|
|
43
|
+
"path": [],
|
|
44
|
+
"tags": []
|
|
45
|
+
},
|
|
46
|
+
{
|
|
47
|
+
"location": "mlvbench.probes.LinearProbe.select_features",
|
|
48
|
+
"level": 3,
|
|
49
|
+
"title": "<code>select_features(features)</code>",
|
|
50
|
+
"text": "<p>Select the part of the feature representation used by the probe.</p> <p>Defaults to the patch tokens of <code>self.layer</code> with shape <code>(B, N, C)</code>. Override to read from a different part of the representation (e.g. the cls token or a different token format).</p> <p>Parameters:</p> Name Type Description Default <code>features</code> <code>Features</code> <p>The features extracted from the backbone.</p> required <p>Returns:</p> Type Description <code>Tensor</code> <p>The selected feature tensor.</p>",
|
|
51
|
+
"path": [],
|
|
52
|
+
"tags": []
|
|
53
|
+
},
|
|
54
|
+
{
|
|
55
|
+
"location": "mlvbench.probes.LinearProbe.serialize",
|
|
56
|
+
"level": 3,
|
|
57
|
+
"title": "<code>serialize()</code>",
|
|
58
|
+
"text": "<p>Serialize the probe.</p> <p>See <code>Probe.serialize</code>.</p>",
|
|
59
|
+
"path": [],
|
|
60
|
+
"tags": []
|
|
61
|
+
},
|
|
62
|
+
{
|
|
63
|
+
"location": "mlvbench.probes.Probe",
|
|
64
|
+
"level": 2,
|
|
65
|
+
"title": "<code>Probe</code>",
|
|
66
|
+
"text": "<p> Bases: <code>Module</code>, <code>ABC</code></p> <p>Abstract base class for probes.</p> <p>Attributes:</p> Name Type Description <code>name</code> <code>str</code> <p>Name of the probe type.</p> <code>layer</code> <code>str</code> <p>Name of the backbone layer the probe reads from.</p> <code>metadata</code> <code>dict[str, Any]</code> <p>Free-form dict of training/experiment information attached to the probe. Persisted in full when the probe is saved.</p>",
|
|
67
|
+
"path": [],
|
|
68
|
+
"tags": []
|
|
69
|
+
},
|
|
70
|
+
{
|
|
71
|
+
"location": "mlvbench.probes.Probe.name",
|
|
72
|
+
"level": 3,
|
|
73
|
+
"title": "<code>name</code> <code>abstractmethod</code> <code>property</code>",
|
|
74
|
+
"text": "<p>Name of the probe type.</p>",
|
|
75
|
+
"path": [],
|
|
76
|
+
"tags": []
|
|
77
|
+
},
|
|
78
|
+
{
|
|
79
|
+
"location": "mlvbench.probes.Probe.__init__",
|
|
80
|
+
"level": 3,
|
|
81
|
+
"title": "<code>__init__(layer, input_dim, *, metadata=None)</code>",
|
|
82
|
+
"text": "<p>Initialize the probe.</p> <p>Parameters:</p> Name Type Description Default <code>layer</code> <code>str</code> <p>Name of the model layer the probe reads from.</p> required <code>input_dim</code> <code>int</code> <p>Number of dimensions of the input features.</p> required <code>metadata</code> <code>dict[str, Any] | None</code> <p>Free-form dict of training/experiment information.</p> <code>None</code>",
|
|
83
|
+
"path": [],
|
|
84
|
+
"tags": []
|
|
85
|
+
},
|
|
86
|
+
{
|
|
87
|
+
"location": "mlvbench.probes.Probe.forward",
|
|
88
|
+
"level": 3,
|
|
89
|
+
"title": "<code>forward(features)</code> <code>abstractmethod</code>",
|
|
90
|
+
"text": "<p>Apply the probe to the given features.</p> <p>The probe selects the part of the representation it reads from via <code>select_features</code>.</p> <p>Parameters:</p> Name Type Description Default <code>features</code> <code>Features</code> <p>The features extracted from the backbone.</p> required <p>Returns:</p> Type Description <code>Tensor</code> <p>The prediction from the probe as torch.Tensor. Shape and dtype very per probe.</p>",
|
|
91
|
+
"path": [],
|
|
92
|
+
"tags": []
|
|
93
|
+
},
|
|
94
|
+
{
|
|
95
|
+
"location": "mlvbench.probes.Probe.select_features",
|
|
96
|
+
"level": 3,
|
|
97
|
+
"title": "<code>select_features(features)</code>",
|
|
98
|
+
"text": "<p>Select the part of the feature representation used by the probe.</p> <p>Defaults to the patch tokens of <code>self.layer</code> with shape <code>(B, N, C)</code>. Override to read from a different part of the representation (e.g. the cls token or a different token format).</p> <p>Parameters:</p> Name Type Description Default <code>features</code> <code>Features</code> <p>The features extracted from the backbone.</p> required <p>Returns:</p> Type Description <code>Tensor</code> <p>The selected feature tensor.</p>",
|
|
99
|
+
"path": [],
|
|
100
|
+
"tags": []
|
|
101
|
+
},
|
|
102
|
+
{
|
|
103
|
+
"location": "mlvbench.probes.Probe.serialize",
|
|
104
|
+
"level": 3,
|
|
105
|
+
"title": "<code>serialize()</code> <code>abstractmethod</code>",
|
|
106
|
+
"text": "<p>Return all information needed to reconstruct the probe.</p> <p>This returns a self-describing dictionary that includes both the torch <code>state_dict</code> and all config options. The probe can be rebuilt from this representation via <code>build_probe</code>.</p> <p>Returns:</p> Type Description <code>dict[str, Any]</code> <p>A dictionary describing the probe, with detached CPU tensors for <code>weights</code>.</p>",
|
|
107
|
+
"path": [],
|
|
108
|
+
"tags": []
|
|
109
|
+
},
|
|
110
|
+
{
|
|
111
|
+
"location": "mlvbench.probes.build_probe",
|
|
112
|
+
"level": 2,
|
|
113
|
+
"title": "<code>build_probe(name, layer, input_dim, metadata=None, state_dict=None, probe_types=None, **kwargs)</code>",
|
|
114
|
+
"text": "<p>Build the probe with the given name and arguments.</p> <p>Parameters:</p> Name Type Description Default <code>name</code> <code>str</code> <p>Name of the probe type (e.g. <code>\"linear\"</code>).</p> required <code>layer</code> <code>str</code> <p>Name of the model layer the probe reads from.</p> required <code>input_dim</code> <code>int</code> <p>Number of dimensions of the input features.</p> required <code>metadata</code> <code>dict[str, Any] | None</code> <p>Free-form metadata to attach to the probe.</p> <code>None</code> <code>state_dict</code> <code>dict[str, Any] | None</code> <p>Optional state dict for restoring pretrained probes.</p> <code>None</code> <code>probe_types</code> <code>dict[str, type[Probe]] | None</code> <p>Optional mapping of custom probe type names to <code>Probe</code> subclasses, merged with the built-in types. Each class must be constructible as <code>Cls(layer, input_dim, metadata=metadata, **kwargs)</code>.</p> <code>None</code> <code>**kwargs</code> <code>Any</code> <p>Additional keyword arguments forwarded to the probe constructor (e.g. <code>bias</code> and <code>num_patches</code>).</p> <code>{}</code> <p>Raises:</p> Type Description <code>ValueError</code> <p>If <code>name</code> is not a known built-in or custom probe type.</p>",
|
|
115
|
+
"path": [],
|
|
116
|
+
"tags": []
|
|
117
|
+
}
|
|
118
|
+
],
|
|
119
|
+
"title": "mlvbench.probes",
|
|
120
|
+
"toc": [
|
|
121
|
+
{
|
|
122
|
+
"title": "mlvbench.probes",
|
|
123
|
+
"content": "<code>mlvbench.probes</code>",
|
|
124
|
+
"id": "mlvbenchprobes",
|
|
125
|
+
"url": "#mlvbenchprobes",
|
|
126
|
+
"children": [
|
|
127
|
+
{
|
|
128
|
+
"title": "probes",
|
|
129
|
+
"content": "probes",
|
|
130
|
+
"id": "mlvbench.probes",
|
|
131
|
+
"url": "#mlvbench.probes",
|
|
132
|
+
"children": [],
|
|
133
|
+
"level": 2
|
|
134
|
+
},
|
|
135
|
+
{
|
|
136
|
+
"title": "LinearProbe",
|
|
137
|
+
"content": "LinearProbe",
|
|
138
|
+
"id": "mlvbench.probes.LinearProbe",
|
|
139
|
+
"url": "#mlvbench.probes.LinearProbe",
|
|
140
|
+
"children": [
|
|
141
|
+
{
|
|
142
|
+
"title": "name",
|
|
143
|
+
"content": "name",
|
|
144
|
+
"id": "mlvbench.probes.LinearProbe.name",
|
|
145
|
+
"url": "#mlvbench.probes.LinearProbe.name",
|
|
146
|
+
"children": [],
|
|
147
|
+
"level": 3
|
|
148
|
+
},
|
|
149
|
+
{
|
|
150
|
+
"title": "__init__",
|
|
151
|
+
"content": "__init__",
|
|
152
|
+
"id": "mlvbench.probes.LinearProbe.__init__",
|
|
153
|
+
"url": "#mlvbench.probes.LinearProbe.__init__",
|
|
154
|
+
"children": [],
|
|
155
|
+
"level": 3
|
|
156
|
+
},
|
|
157
|
+
{
|
|
158
|
+
"title": "forward",
|
|
159
|
+
"content": "forward",
|
|
160
|
+
"id": "mlvbench.probes.LinearProbe.forward",
|
|
161
|
+
"url": "#mlvbench.probes.LinearProbe.forward",
|
|
162
|
+
"children": [],
|
|
163
|
+
"level": 3
|
|
164
|
+
},
|
|
165
|
+
{
|
|
166
|
+
"title": "select_features",
|
|
167
|
+
"content": "select_features",
|
|
168
|
+
"id": "mlvbench.probes.LinearProbe.select_features",
|
|
169
|
+
"url": "#mlvbench.probes.LinearProbe.select_features",
|
|
170
|
+
"children": [],
|
|
171
|
+
"level": 3
|
|
172
|
+
},
|
|
173
|
+
{
|
|
174
|
+
"title": "serialize",
|
|
175
|
+
"content": "serialize",
|
|
176
|
+
"id": "mlvbench.probes.LinearProbe.serialize",
|
|
177
|
+
"url": "#mlvbench.probes.LinearProbe.serialize",
|
|
178
|
+
"children": [],
|
|
179
|
+
"level": 3
|
|
180
|
+
}
|
|
181
|
+
],
|
|
182
|
+
"level": 2
|
|
183
|
+
},
|
|
184
|
+
{
|
|
185
|
+
"title": "Probe",
|
|
186
|
+
"content": "Probe",
|
|
187
|
+
"id": "mlvbench.probes.Probe",
|
|
188
|
+
"url": "#mlvbench.probes.Probe",
|
|
189
|
+
"children": [
|
|
190
|
+
{
|
|
191
|
+
"title": "name",
|
|
192
|
+
"content": "name",
|
|
193
|
+
"id": "mlvbench.probes.Probe.name",
|
|
194
|
+
"url": "#mlvbench.probes.Probe.name",
|
|
195
|
+
"children": [],
|
|
196
|
+
"level": 3
|
|
197
|
+
},
|
|
198
|
+
{
|
|
199
|
+
"title": "__init__",
|
|
200
|
+
"content": "__init__",
|
|
201
|
+
"id": "mlvbench.probes.Probe.__init__",
|
|
202
|
+
"url": "#mlvbench.probes.Probe.__init__",
|
|
203
|
+
"children": [],
|
|
204
|
+
"level": 3
|
|
205
|
+
},
|
|
206
|
+
{
|
|
207
|
+
"title": "forward",
|
|
208
|
+
"content": "forward",
|
|
209
|
+
"id": "mlvbench.probes.Probe.forward",
|
|
210
|
+
"url": "#mlvbench.probes.Probe.forward",
|
|
211
|
+
"children": [],
|
|
212
|
+
"level": 3
|
|
213
|
+
},
|
|
214
|
+
{
|
|
215
|
+
"title": "select_features",
|
|
216
|
+
"content": "select_features",
|
|
217
|
+
"id": "mlvbench.probes.Probe.select_features",
|
|
218
|
+
"url": "#mlvbench.probes.Probe.select_features",
|
|
219
|
+
"children": [],
|
|
220
|
+
"level": 3
|
|
221
|
+
},
|
|
222
|
+
{
|
|
223
|
+
"title": "serialize",
|
|
224
|
+
"content": "serialize",
|
|
225
|
+
"id": "mlvbench.probes.Probe.serialize",
|
|
226
|
+
"url": "#mlvbench.probes.Probe.serialize",
|
|
227
|
+
"children": [],
|
|
228
|
+
"level": 3
|
|
229
|
+
}
|
|
230
|
+
],
|
|
231
|
+
"level": 2
|
|
232
|
+
},
|
|
233
|
+
{
|
|
234
|
+
"title": "build_probe",
|
|
235
|
+
"content": "build_probe",
|
|
236
|
+
"id": "mlvbench.probes.build_probe",
|
|
237
|
+
"url": "#mlvbench.probes.build_probe",
|
|
238
|
+
"children": [],
|
|
239
|
+
"level": 2
|
|
240
|
+
}
|
|
241
|
+
],
|
|
242
|
+
"level": 1
|
|
243
|
+
}
|
|
244
|
+
]
|
|
245
|
+
},
|
|
246
|
+
"hash": 17128207827365371114
|
|
247
|
+
}
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
{
|
|
2
|
+
"data": {
|
|
3
|
+
"meta": {},
|
|
4
|
+
"content": "<h1 id=\"mlvbenchinfrastructure\"><code>mlvbench.infrastructure</code><a class=\"headerlink\" href=\"#mlvbenchinfrastructure\" title=\"Permanent link\">¶</a></h1>\n\n\n<div class=\"doc doc-object doc-module\">\n\n\n\n<a id=\"mlvbench.infrastructure\"></a>\n <div class=\"doc doc-contents first\">\n\n <p>Infrastructure utilities.</p>\n\n\n\n\n\n\n\n\n\n\n<div class=\"doc doc-children\">\n\n\n\n\n\n\n\n\n\n\n<div class=\"doc doc-object doc-function\">\n\n\n<h2 id=\"mlvbench.infrastructure.resolve_layers\" class=\"doc doc-heading\">\n <code class=\"highlight language-python\"><span class=\"n\">resolve_layers</span><span class=\"p\">(</span><span class=\"n\">all_layers</span><span class=\"p\">,</span> <span class=\"n\">layers_spec</span><span class=\"p\">)</span></code>\n\n<a href=\"#mlvbench.infrastructure.resolve_layers\" class=\"headerlink\" title=\"Permanent link\">¶</a></h2>\n\n\n <div class=\"doc doc-contents \">\n\n <p>Resolve a layer specification string to a list of layer names.</p>\n<p>Intended for experiment scripts that expose a <code>--layers</code> command line argument.\nThe resolved list can be passed directly to\n<autoref identifier=\"mlvbench.trainer.ProbeTrainer.fit\"><code>ProbeTrainer.fit</code></autoref>.</p>\n\n\n<p><span class=\"doc-section-title\">Parameters:</span></p>\n <table>\n <thead>\n <tr>\n <th>Name</th>\n <th>Type</th>\n <th>Description</th>\n <th>Default</th>\n </tr>\n </thead>\n <tbody>\n <tr class=\"doc-section-item\">\n <td>\n <code>all_layers</code>\n </td>\n <td>\n <code><autoref identifier=\"list\" backlink-type=\"used-by\" backlink-anchor=\"mlvbench.infrastructure.resolve_layers\" optional>list</autoref>[<autoref identifier=\"str\" backlink-type=\"used-by\" backlink-anchor=\"mlvbench.infrastructure.resolve_layers\" optional>str</autoref>]</code>\n </td>\n <td>\n <div class=\"doc-md-description\">\n <p>The full list of layer names from the model\n(<code>model.layer_names</code>).</p>\n </div>\n </td>\n <td>\n <em>required</em>\n </td>\n </tr>\n <tr class=\"doc-section-item\">\n <td>\n <code>layers_spec</code>\n </td>\n <td>\n <code><autoref identifier=\"str\" backlink-type=\"used-by\" backlink-anchor=\"mlvbench.infrastructure.resolve_layers\" optional>str</autoref> | None</code>\n </td>\n <td>\n <div class=\"doc-md-description\">\n <p>A specification of a list of layers, provided as a comma-separated\nstring. Each value may be a non-negative index (e.g. 0), a negative index\n(e.g. -1), or a layer name (e.g. block.12). If None, all layers are\nreturned.</p>\n </div>\n </td>\n <td>\n <em>required</em>\n </td>\n </tr>\n </tbody>\n </table>\n\n\n <p><span class=\"doc-section-title\">Returns:</span></p>\n <table>\n <thead>\n <tr>\n <th>Type</th>\n <th>Description</th>\n </tr>\n </thead>\n <tbody>\n <tr class=\"doc-section-item\">\n <td>\n <code><autoref identifier=\"list\" backlink-type=\"returned-by\" backlink-anchor=\"mlvbench.infrastructure.resolve_layers\" optional>list</autoref>[<autoref identifier=\"str\" backlink-type=\"returned-by\" backlink-anchor=\"mlvbench.infrastructure.resolve_layers\" optional>str</autoref>]</code>\n </td>\n <td>\n <div class=\"doc-md-description\">\n <p>A deduplicated list of resolved layer names.</p>\n </div>\n </td>\n </tr>\n </tbody>\n </table>\n\n\n </div>\n\n</div>\n\n<div class=\"doc doc-object doc-function\">\n\n\n<h2 id=\"mlvbench.infrastructure.save_metadata\" class=\"doc doc-heading\">\n <code class=\"highlight language-python\"><span class=\"n\">save_metadata</span><span class=\"p\">(</span><span class=\"n\">output_path</span><span class=\"p\">,</span> <span class=\"n\">parameters</span><span class=\"p\">)</span></code>\n\n<a href=\"#mlvbench.infrastructure.save_metadata\" class=\"headerlink\" title=\"Permanent link\">¶</a></h2>\n\n\n <div class=\"doc doc-contents \">\n\n <p>Save the metadata for an experiment run.</p>\n\n\n </div>\n\n</div>\n\n<div class=\"doc doc-object doc-function\">\n\n\n<h2 id=\"mlvbench.infrastructure.save_model_info\" class=\"doc doc-heading\">\n <code class=\"highlight language-python\"><span class=\"n\">save_model_info</span><span class=\"p\">(</span><span class=\"n\">output_path</span><span class=\"p\">,</span> <span class=\"n\">model</span><span class=\"p\">)</span></code>\n\n<a href=\"#mlvbench.infrastructure.save_model_info\" class=\"headerlink\" title=\"Permanent link\">¶</a></h2>\n\n\n <div class=\"doc doc-contents \">\n\n <p>Save model info for an experiment run.</p>\n\n\n </div>\n\n</div>\n\n\n\n </div>\n\n </div>\n\n</div>",
|
|
5
|
+
"search": [
|
|
6
|
+
{
|
|
7
|
+
"location": null,
|
|
8
|
+
"level": 1,
|
|
9
|
+
"title": "<code>mlvbench.infrastructure</code>",
|
|
10
|
+
"text": "<p>Infrastructure utilities.</p>",
|
|
11
|
+
"path": [],
|
|
12
|
+
"tags": []
|
|
13
|
+
},
|
|
14
|
+
{
|
|
15
|
+
"location": "mlvbench.infrastructure.resolve_layers",
|
|
16
|
+
"level": 2,
|
|
17
|
+
"title": "<code>resolve_layers(all_layers, layers_spec)</code>",
|
|
18
|
+
"text": "<p>Resolve a layer specification string to a list of layer names.</p> <p>Intended for experiment scripts that expose a <code>--layers</code> command line argument. The resolved list can be passed directly to <code>ProbeTrainer.fit</code>.</p> <p>Parameters:</p> Name Type Description Default <code>all_layers</code> <code>list[str]</code> <p>The full list of layer names from the model (<code>model.layer_names</code>).</p> required <code>layers_spec</code> <code>str | None</code> <p>A specification of a list of layers, provided as a comma-separated string. Each value may be a non-negative index (e.g. 0), a negative index (e.g. -1), or a layer name (e.g. block.12). If None, all layers are returned.</p> required <p>Returns:</p> Type Description <code>list[str]</code> <p>A deduplicated list of resolved layer names.</p>",
|
|
19
|
+
"path": [],
|
|
20
|
+
"tags": []
|
|
21
|
+
},
|
|
22
|
+
{
|
|
23
|
+
"location": "mlvbench.infrastructure.save_metadata",
|
|
24
|
+
"level": 2,
|
|
25
|
+
"title": "<code>save_metadata(output_path, parameters)</code>",
|
|
26
|
+
"text": "<p>Save the metadata for an experiment run.</p>",
|
|
27
|
+
"path": [],
|
|
28
|
+
"tags": []
|
|
29
|
+
},
|
|
30
|
+
{
|
|
31
|
+
"location": "mlvbench.infrastructure.save_model_info",
|
|
32
|
+
"level": 2,
|
|
33
|
+
"title": "<code>save_model_info(output_path, model)</code>",
|
|
34
|
+
"text": "<p>Save model info for an experiment run.</p>",
|
|
35
|
+
"path": [],
|
|
36
|
+
"tags": []
|
|
37
|
+
}
|
|
38
|
+
],
|
|
39
|
+
"title": "mlvbench.infrastructure",
|
|
40
|
+
"toc": [
|
|
41
|
+
{
|
|
42
|
+
"title": "mlvbench.infrastructure",
|
|
43
|
+
"content": "<code>mlvbench.infrastructure</code>",
|
|
44
|
+
"id": "mlvbenchinfrastructure",
|
|
45
|
+
"url": "#mlvbenchinfrastructure",
|
|
46
|
+
"children": [
|
|
47
|
+
{
|
|
48
|
+
"title": "infrastructure",
|
|
49
|
+
"content": "infrastructure",
|
|
50
|
+
"id": "mlvbench.infrastructure",
|
|
51
|
+
"url": "#mlvbench.infrastructure",
|
|
52
|
+
"children": [],
|
|
53
|
+
"level": 2
|
|
54
|
+
},
|
|
55
|
+
{
|
|
56
|
+
"title": "resolve_layers",
|
|
57
|
+
"content": "resolve_layers",
|
|
58
|
+
"id": "mlvbench.infrastructure.resolve_layers",
|
|
59
|
+
"url": "#mlvbench.infrastructure.resolve_layers",
|
|
60
|
+
"children": [],
|
|
61
|
+
"level": 2
|
|
62
|
+
},
|
|
63
|
+
{
|
|
64
|
+
"title": "save_metadata",
|
|
65
|
+
"content": "save_metadata",
|
|
66
|
+
"id": "mlvbench.infrastructure.save_metadata",
|
|
67
|
+
"url": "#mlvbench.infrastructure.save_metadata",
|
|
68
|
+
"children": [],
|
|
69
|
+
"level": 2
|
|
70
|
+
},
|
|
71
|
+
{
|
|
72
|
+
"title": "save_model_info",
|
|
73
|
+
"content": "save_model_info",
|
|
74
|
+
"id": "mlvbench.infrastructure.save_model_info",
|
|
75
|
+
"url": "#mlvbench.infrastructure.save_model_info",
|
|
76
|
+
"children": [],
|
|
77
|
+
"level": 2
|
|
78
|
+
}
|
|
79
|
+
],
|
|
80
|
+
"level": 1
|
|
81
|
+
}
|
|
82
|
+
]
|
|
83
|
+
},
|
|
84
|
+
"hash": 12273485971954117959
|
|
85
|
+
}
|