Skip to content

[BUG] NaN when building self.ends #1144

@FactoDeepLearning

Description

@FactoDeepLearning

In sparse_hmm.py, in the unpack_edges function, the initialization of self.ends is dangerous as they are no guarantee that all states will be linked to ending Silence(). So, some values may not be initialized, leading to NaN in my case (prefix-tree implementation with SparseHMM).

https://github.com/jmschrei/pomegranate/blob/master/pomegranate/hmm/sparse_hmm.py#L63

Proposed fix:
Replacing:
self.ends = torch.empty(n, dtype=self.dtype, device=self.device) - inf
by:
self.ends = torch.full((n, ), fill_value=-inf, dtype=self.dtype, device=self.device)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions