Skip to content

Issue running Complete Example #11

Description

@LSgeo

Trying to get started with the project, running the Complete Example at https://opensource.michelin.io/TorchSOM/getting_started/quickstart.html#complete-example. The SOM trains, but has an error in a visualisation step. The indices_tensor is floating point values, so it doesn't seem appropriate to cast to an integer type.

Expected behaviour: Complete example in documentation runs without error.

Training SOM: 100%|█████████████████████████████████████████| 100/100 [00:13<00:00,  7.65epoch/s]
Traceback (most recent call last):
  File "...\som\som_poc.py", line 48, in <module>
    viz.plot_all(
  File "...\.virtualenvs\som\Lib\site-packages\torchsom\visualization\base.py", line 193, in plot_all
    self._visualizer.plot_metric_map(
  File "...\.virtualenvs\som\Lib\site-packages\torchsom\visualization\base_visualizer.py", line 211, in plot_metric_map
    metric_map = self.som.build_map(
                 ^^^^^^^^^^^^^^^^^^^
  File "...\.virtualenvs\som\Lib\site-packages\torchsom\core\som.py", line 642, in build_map
    return map_function(self, bmus_data_map, target, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "...\.virtualenvs\som\Lib\site-packages\torchsom\utils\maps.py", line 241, in build_metric_map
    target_values = target[indices_tensor].float()
                    ~~~~~~^^^^^^^^^^^^^^^^
IndexError: tensors used as indices must be long, int, byte or bool tensors

Python environment, torch/cuda version 2.13.0+cu130

pip list
Package           Version
----------------- ------------
annotated-types   0.8.0
colorama          0.4.6
contourpy         1.3.3
cycler            0.12.1
faiss-cpu         1.14.3
filelock          3.32.0
fonttools         4.63.0
fsspec            2026.7.0
hdbscan           0.8.44
Jinja2            3.1.6
joblib            1.5.3
kiwisolver        1.5.0
MarkupSafe        3.0.3
matplotlib        3.8.4
mpmath            1.3.0
narwhals          2.24.0
networkx          3.6.1
numpy             2.5.1
packaging         26.2
pillow            12.3.0
pip               24.3.1
pydantic          2.13.4
pydantic_core     2.46.4
pyparsing         3.3.2
python-dateutil   2.9.0.post0
scikit-learn      1.9.0
scipy             1.18.0
setuptools        83.0.0
six               1.17.0
sympy             1.14.0
threadpoolctl     3.6.0
torch             2.13.0+cu130
torchsom          1.3.0
tqdm              4.70.0
typing_extensions 4.16.0
typing-inspection 0.4.2

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions