From a62a5dbb5f2ef7bf35dd37a049ddd6c655a4fb37 Mon Sep 17 00:00:00 2001 From: James Betker Date: Wed, 7 Oct 2020 12:41:00 -0600 Subject: [PATCH] Clone and detach in recursively_detach --- codes/utils/util.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/codes/utils/util.py b/codes/utils/util.py index 2dd3378f..c526fecb 100644 --- a/codes/utils/util.py +++ b/codes/utils/util.py @@ -356,7 +356,7 @@ class ProgressBar(object): # Recursively detaches all tensors in a tree of lists, dicts and tuples and returns the same structure. def recursively_detach(v): if isinstance(v, torch.Tensor): - return v.detach() + return v.detach().clone() elif isinstance(v, list) or isinstance(v, tuple): out = [recursively_detach(i) for i in v] if isinstance(v, tuple):