Skip to content

Bug in graph definition in example 01_read_dataset.py #774

Open
@giogiopg

Description

@giogiopg

Describe the bug
The example in examples/02_data/01_read_dataset.py. is crashing due to a mismatch between the default features considered by KNNgraph and the input features given in the example.

To Reproduce

  1. Start your GraphNeT enviroment
  2. Run python examples/02_data/01_read_dataset.py

Full traceback
The error message show is the following one

Traceback (most recent call last):
  File "/lustre/ific.uv.es/ml/ific128/jprado/graphnet_jorge_dev/km3net-graphnet/examples/02_data/01_read_dataset.py", line 126, in <module>
    main(args.backend)
  File "/lustre/ific.uv.es/ml/ific128/jprado/graphnet_jorge_dev/km3net-graphnet/examples/02_data/01_read_dataset.py", line 80, in main
    logger.info(str(dataset[1]))
                    ~~~~~~~^^^
  File "/lustre/ific.uv.es/ml/ific128/jprado/graphnet_jorge_dev/km3net-graphnet/src/graphnet/data/dataset/dataset.py", line 458, in __getitem__
    graph = self._create_graph(features, truth, node_truth, loss_weight)
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/lustre/ific.uv.es/ml/ific128/jprado/graphnet_jorge_dev/km3net-graphnet/src/graphnet/data/dataset/dataset.py", line 647, in _create_graph
    graph = self._graph_definition(
            ^^^^^^^^^^^^^^^^^^^^^^^
  File "/lustre/ific.uv.es/ml/ific128/jprado/graphnet_jorge_dev/km3net-graphnet/cpu_venv/lib/python3.11/site-packages/torch/nn/modules/module.py", line 1511, in _wrapped_call_impl
    return self._call_impl(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/lustre/ific.uv.es/ml/ific128/jprado/graphnet_jorge_dev/km3net-graphnet/cpu_venv/lib/python3.11/site-packages/torch/nn/modules/module.py", line 1520, in _call_impl
    return forward_call(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/lustre/ific.uv.es/ml/ific128/jprado/graphnet_jorge_dev/km3net-graphnet/src/graphnet/models/graphs/graph_definition.py", line 183, in forward
    self._validate_input(
  File "/lustre/ific.uv.es/ml/ific128/jprado/graphnet_jorge_dev/km3net-graphnet/src/graphnet/models/graphs/graph_definition.py", line 336, in _validate_input
    assert len(input_feature_names) == len(
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
AssertionError: Input features (['dom_x', 'dom_y', 'dom_z', 'dom_time', 'charge', 'rde', 'pmt_area']) is not what 
               KNNGraph was instatiated
               with (['dom_x', 'dom_y', 'dom_z', 'dom_time', 'charge', 'rde', 'pmt_area', 'hlc'])```

Additional context
In order to fix this error, it is just needed to instantiate the graph in the 01_read_dataset.py script with:

graph_definition = KNNGraph(detector=IceCubeDeepCore(), 
                                input_feature_names = ['dom_x', 'dom_y', 'dom_z', 'dom_time', 'charge', 'rde', 'pmt_area'])

instead of how it is currently instantiated with:

graph_definition = KNNGraph(detector=IceCubeDeepCore())

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions