Private archive copy · Unofficial site · Content copyright belongs to Runoob Tutorial and the original authors · View Original

PyTorch torch.set_warn_always function

PyTorch torch.set_warn_always function


PyTorch torch reference manual PyTorch torch reference manual

torch.set_warn_always is a function in PyTorch used to set whether warnings are always shown. When enabled, PyTorch always shows deprecation warnings, even if those warnings have already been ignored.

Function definition

torch.set_warn_always(warn)

Parameter Description


Usage examples

Example

import

torch

Set to always show warnings

torch.

set_warn_always

(

True

)

print

(

"Warnings have been set to always show"

)

Restore default behavior

torch.

set_warn_always

(

False

)

print

(

"Warnings have been restored to default behavior"

)

The output is:

警告已设置为始终显示

警告已恢复默认行为


PyTorch torch reference manual PyTorch torch reference manual