[New-bugs-announce] [issue42530] Pickle Serialization Mangles NllLossBackward Objects in Tensor Objects

Daniel Kostecki report at bugs.python.org
Wed Dec 2 01:23:16 EST 2020


New submission from Daniel Kostecki <dandankostecki at gmail.com>:

torch.nn.functional.nll_loss returns Tensor objects which contain a loss value as well as a grad_fn object. Pickle does not throw an exception when serializing (dumps) the Tensor object. When loading (loads) the serialized data, the grad_fn object is lost and it becomes a requires_grad object. 

However, if one attempts to serialize the grad_fn object encapsulated in the Tensor object, Pickle then throws a TypeError (TypeError: cannot pickle 'NllLossBackward' object). This behavior seems inconsistent. Perhaps serialization of NllLossBackward objects should be supported or their encapsulating Tensors should also throw a TypeError.

This behavior should be easily reproducible.

----------
components: Library (Lib)
messages: 382294
nosy: dkostecki
priority: normal
severity: normal
status: open
title: Pickle Serialization Mangles NllLossBackward Objects in Tensor Objects
type: behavior
versions: Python 3.8

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue42530>
_______________________________________


More information about the New-bugs-announce mailing list