mirror of
https://github.com/zebrajr/pytorch.git
synced 2025-12-06 12:20:52 +01:00
Revise error message for invalid Reduction (#22160)
Summary:
Say the user inputs reduction=False. Of course, we can't add a bool and a string, so the ValueError itself will error -which is more confusing to the user. Instead, we should use string formatting. I would use `f"{reduction} is not..."` but unsure whether we are ok with using f"" strings.
Pull Request resolved: https://github.com/pytorch/pytorch/pull/22160
Differential Revision: D15981826
Pulled By: soumith
fbshipit-source-id: 279f34bb64a72578c36bdbabe2da83d2fa4b93d8
This commit is contained in:
parent
9e18234109
commit
b52621c870
|
|
@ -18,7 +18,7 @@ def get_enum(reduction):
|
|||
ret = 2
|
||||
else:
|
||||
ret = -1 # TODO: remove once JIT exceptions support control flow
|
||||
raise ValueError(reduction + " is not a valid value for reduction")
|
||||
raise ValueError("{} is not a valid value for reduction".format(reduction))
|
||||
return ret
|
||||
|
||||
# In order to support previous versions, accept boolean size_average and reduce
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user