forked from mrq/DL-Art-School
Clone and detach in recursively_detach
This commit is contained in:
parent
1c44d395af
commit
a62a5dbb5f
|
@ -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):
|
||||
|
|
Loading…
Reference in New Issue
Block a user