Skip to content
This repository has been archived by the owner on Jul 2, 2021. It is now read-only.

Perform batch size check before converting scales #762

Merged
merged 2 commits into from
Feb 1, 2019
Merged

Perform batch size check before converting scales #762

merged 2 commits into from
Feb 1, 2019

Conversation

23pointsNorth
Copy link
Contributor

@23pointsNorth 23pointsNorth commented Jan 31, 2019

If batch size 2 is used, it fails with

scale = np.asscalar(cuda.to_cpu(scale))
  File "...numpy/lib/type_check.py", line 482, in asscalar
    return a.item()
ValueError: can only convert an array of size 1 to a Python scalar

Proposed outcome:
By reordering the checks, the ValueError would be raised before the conversion, avoiding this error.

System:

numpy       1.14.2
chainer     5.1.0                  
chainercv   0.11.0  

If batch size 2 is used, it fails with
```
    scale = np.asscalar(cuda.to_cpu(scale))
  File "...numpy/lib/type_check.py", line 482, in asscalar
    return a.item()
ValueError: can only convert an array of size 1 to a Python scalar
```
Proposed outcome:
By reordering the checks, the RaiseValue Error would be raised before the conversion, avoiding this error.
@yuyu2172
Copy link
Member

yuyu2172 commented Feb 1, 2019

Thank for sending the PR!

@yuyu2172 yuyu2172 added this to the 0.12 milestone Feb 1, 2019
@yuyu2172 yuyu2172 self-assigned this Feb 1, 2019
@yuyu2172 yuyu2172 merged commit a825040 into chainer:master Feb 1, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants