Skip to content

ValueError: NaN encountered in calc_diversity when enabling diversity evaluation #18

@111bnh

Description

@111bnh

Hi,

I encountered an issue when running evaluate.py. In order to check the diversity metrics of the model, I uncommented lines 227-228 to enable diversity.calc_diversity(): [https://github.com/iSEE-Laboratory/DGTR/blob/226bf457483330aa8d6be464e69c25305428caa0/tools/evaluate.py#L227-L228]

DGTR/tools/evaluate.py

Lines 227 to 228 in 226bf45

# diversity = DiversityEvalator(temp_result_path, performance_results)
# final_result = diversity.calc_diversity()

However, after the evaluation progress reached 100%, the program crashed during the final calculation step. The traceback indicates that NaN values were generated in the probs tensor within the _calc_entropy function, which caused torch.distributions.Categorical to fail because the Simplex constraint was not satisfied.

The specific error log is as follows:
Evaluate: 100%|██████████████████████████████████| 1126/1126 [3:59:08<00:00, 12.74s/it, q1=0.1, pen=0.01, valid_q1=0.03]

Finished in 14362.68s
Removing ./Experiments/dgtr/test_results/epoch_25/metrics_0_1126.json

Traceback (most recent call last):
File "./tools/evaluate.py", line 228, in
final_result = diversity.calc_diversity()
File "./tools/evaluate.py", line 127, in calc_diversity
mean_entropy_joints = self._calc_entropy(joint_angles)
File "./tools/evaluate.py", line 181, in _calc_entropy
distribution = torch.distributions.Categorical(probs=prob)
File ".../torch/distributions/categorical.py", line 64, in init
super(Categorical, self).init(batch_shape, validate_args=validate_args)
File ".../torch/distributions/distribution.py", line 55, in init
raise ValueError(
ValueError: Expected parameter probs (Tensor of shape (100,)) of distribution Categorical(probs: torch.Size([100])) to satisfy the constraint Simplex(), but found invalid values:
tensor([nan, nan, ... (omitted) ... nan])

Could you please advise on what might be causing this? Is it likely due to invalid generated joint angles, or is there a potential division-by-zero issue in the entropy calculation logic?

Thanks in advance for your help!

DGTR/tools/evaluate.py

Lines 227 to 228 in 226bf45

# diversity = DiversityEvalator(temp_result_path, performance_results)
# final_result = diversity.calc_diversity()

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