Skip to content
This repository has been archived by the owner on Nov 22, 2022. It is now read-only.

RuntimeError: bool value of Tensor with more than one value is ambiguous #934

Closed
deepali-c opened this issue Aug 23, 2019 · 4 comments
Closed

Comments

@deepali-c
Copy link

Steps to reproduce

Execute steps to test Custom Tensorizer - https://pytext.readthedocs.io/en/master/tensorizer.html

Observed Results

    assert words_tensors == tensor([[2, 3, 4, 5], [6, 7, 8, 1]])
RuntimeError: bool value of Tensor with more than one value is ambiguous

Expected Results

The test should pass.

@deepali-c
Copy link
Author

Updating code locally to correctly compare the tensors at the end helps here.
The example in the document needs to be updated likewise:

assert torch.all(torch.eq(words_tensors, tensor([[2, 3, 4, 5], [6, 7, 8, 1]])))
assert torch.all(torch.eq(seq_len_tensors, tensor([4, 3])))

hudeven added a commit to hudeven/pytext that referenced this issue Aug 26, 2019
1. "==" is equivalent to torch.eq() which returns multi-dimensional Tensor and causes "RuntimeError: bool value of Tensor with more than one value is ambiguous" facebookresearch#934
2. torch.equal(): returns True if two tensors have the same size and elements, False otherwise.
@deepali-c
Copy link
Author

Thanks @hudeven :-) .

@deepali-c
Copy link
Author

One more thing, there is an additional bracket at the following line -
words_tensors, seq_len_tensors = tensorizer.tensorize(numberized_rows))

facebook-github-bot pushed a commit that referenced this issue Aug 28, 2019
Summary:
#528  Motivation and Context

1. "==" is equivalent to torch.eq() which returns multi-dimensional Tensor and causes "RuntimeError: bool value of Tensor with more than one value is ambiguous"
2. torch.equal(): returns True if two tensors have the same size and elements, False otherwise.

#934

## How Has This Been Tested

N/A, tutorial update
## Types of changes

- [x] Docs change / refactoring / dependency upgrade
- [ ] Bug fix (non-breaking change which fixes an issue)
- [ ] New feature (non-breaking change which adds functionality)
- [ ] Breaking change (fix or feature that would cause existing functionality to change)

## Checklist

- [x] My code follows the code style of this project.
- [x] My change requires a change to the documentation.
- [x] I have updated the documentation accordingly.
- [x] I have read the **CONTRIBUTING** document.
- [x] I have completed my CLA (see **CONTRIBUTING**)
- [ ] I have added tests to cover my changes.
- [x] All new and existing tests passed.
Pull Request resolved: #939

Reviewed By: chenyangyu1988

Differential Revision: D17102957

Pulled By: hudeven

fbshipit-source-id: 8b584b895b459bcd84f24286535b8b16f0093d88
mwu1993 pushed a commit to mwu1993/pytext-1 that referenced this issue Sep 11, 2019
Summary: facebookresearch#934

Reviewed By: chenyangyu1988

Differential Revision: D17295128

fbshipit-source-id: 011b034cf7ccaee0752263f8ce86b1889f2ea923
facebook-github-bot pushed a commit that referenced this issue Sep 11, 2019
Summary:
Pull Request resolved: #971

#934

Reviewed By: chenyangyu1988

Differential Revision: D17295128

fbshipit-source-id: 5700333fbb8479b4d3bfd828c193bd2f134fae9a
@mwu1993
Copy link
Contributor

mwu1993 commented Sep 11, 2019

#971

@mwu1993 mwu1993 closed this as completed Sep 11, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants