From 45764b5721e18518b67794f3b52ecdba17ec3d37 Mon Sep 17 00:00:00 2001 From: Vincent Moens Date: Thu, 15 Feb 2024 13:43:48 +0000 Subject: [PATCH] [BugFix] Use setdefault in _cache_values (#1910) --- torchrl/objectives/utils.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/torchrl/objectives/utils.py b/torchrl/objectives/utils.py index b234af6a804..9afbf8095f0 100644 --- a/torchrl/objectives/utils.py +++ b/torchrl/objectives/utils.py @@ -459,7 +459,7 @@ def _cache_values(fun): def new_fun(self, netname=None): __dict__ = self.__dict__ - _cache = __dict__["_cache"] + _cache = __dict__.setdefault("_cache", {}) attr_name = name if netname is not None: attr_name += "_" + netname