Incorrect tensor type in scitail.nn.util.masked_mean
- Langage dominant
- Python
- Étoiles
- 52
- Forks
- 11
- Métriques de merge des PR
- Aucune PR mergée en 30 j
Description
### System information
- Ubuntu 16.04
- Anaconda 4.5.11
- PyTorch 0.4.1
- CUDA 9.0
- NVIDIA Driver 396.54
### Producing the error
`pytest -v` produces the following stacktrace:
```
def masked_mean(tensor, dim, mask):
"""
``Performs a mean on just the non-masked portions of the ``tensor`` in the
``dim`` dimension of the tensor.
"""
if mask is None:
return torch.mean(tensor, dim)
if tensor.dim() != mask.dim():
raise ConfigurationError("tensor.dim() (%d) != mask.dim() (%d)" % (tensor.dim(), mask.dim()))
masked_tensor = replace_masked_values(tensor, mask, 0.0)
# total value
total_tensor = torch.sum(masked_tensor, dim)
# count
count_tensor = torch.sum((mask != 0), dim)
# set zero count to 1 to avoid nans
#zero_count_mask = (count_tensor == 0).long()
zero_count_mask = (count_tensor == 0)
> count_plus_zeros = (count_tensor + zero_count_mask).float()
E RuntimeError: Expected object of type torch.LongTensor but found type torch.ByteTensor for argument #3 'other'
```
### Possible fix
Changing https://github.com/allenai/scitail/blob/2e57f46a4620d50e85323c4a642114426db67393/scitail/nn/util.py#L24 to
```python
zero_count_mask = (count_tensor == 0).long()
```
seems to fix the error.
Guide de contribution
Aucun guide de contribution indexé pour ce dépôt
Évaluation
Cette issue n'a pas encore été évaluée.