harvardnlp / pytorch-struct

Fast, general, and tested differentiable structured prediction in PyTorch
http://harvardnlp.github.io/pytorch-struct
MIT License
1.11k stars 93 forks source link

pytorch-struct shows a warning for torch versions >= 1.8.0 #120

Closed goncalomcorreia closed 2 years ago

goncalomcorreia commented 2 years ago

When using pytorch-struct while using torch>=1.8.0, the following warning appears:

In [1]: import torch
   ...: from torch_struct import DependencyCRF, LinearChainCRF

In [2]: vals = torch.zeros(2, 10, 10) + 1e-5
   ...: vals[:, :5, :5] = torch.rand(5)
   ...: vals[:, 5:, 5:] = torch.rand(5)
   ...: dist = DependencyCRF(vals.log())
/Users/goncalocorreia/.pyenv/versions/3.8.1/envs/struct/lib/python3.8/site-packages/torch/distributions/distribution.py:44: UserWarning: <class 'torch_struct.distributions.DependencyCRF'> does not define `arg_constraints`. Please set `arg_constraints = {}` or initialize the distribution with `validate_args=False` to turn off validation.
  warnings.warn(f'{self.__class__} does not define `arg_constraints`. ' +
srush commented 2 years ago

Oh this should be straightforward to fix. Will patch soon.

goncalomcorreia commented 2 years ago

cool! thanks