Skip to content

Diagnostics Cannot Deal with ndim=2 and ndim=3 parameters #464

@stefanradev93

Description

@stefanradev93

Bug Description
For complex cases, where the simulator returns a bunch of ndim=2 parameters, e.g., (batch_size, D) as well as ndim=1 parameter, e.g., (batch_size, ), the ndim=1 parameters need to be expanded in order to be properly concatenated. This works fine until diagnostics needs to be computed for all parameters, where we now have a bunch of (batch_size, num_samples, D) and (batch_size, num_samples) samples. Since our diagnostics expect at least ndim=3 for estimates and at least ndim=2 for targets, the functions fail with

Expected behavior
The diagnostic functions should be able to deal with mixed ndims and add a trailing dim when missing.

Traceback

    234     raise TypeError(f"Only dicts and tensors are supported as arguments, but your estimates are of type {type(x)}")
    236 if len(variable_names) != x.shape[-1]:
--> 237     raise ValueError("Length of 'variable_names' should be the same as the number of variables.")
    239 if variable_keys is None:
    240     # every variable will count as its own key if not otherwise specified
    241     variable_keys = variable_names

ValueError: Length of 'variable_names' should be the same as the number of variables.

Environment

  • BayesFlow Version: [e.g. 2.0.3]

Metadata

Metadata

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