MCPcopy Create free account
hub / github.com/FreeformRobotics/OTS / as_numpy

Function as_numpy

lib/utils/th.py:18–28  ·  view source on GitHub ↗
(obj)

Source from the content-addressed store, hash-verified

16 return Variable(obj)
17
18def as_numpy(obj):
19 if isinstance(obj, collections.Sequence):
20 return [as_numpy(v) for v in obj]
21 elif isinstance(obj, collections.Mapping):
22 return {k: as_numpy(v) for k, v in obj.items()}
23 elif isinstance(obj, Variable):
24 return obj.data.cpu().numpy()
25 elif torch.is_tensor(obj):
26 return obj.cpu().numpy()
27 else:
28 return np.array(obj)
29
30def mark_volatile(obj):
31 if torch.is_tensor(obj):

Callers 1

get_object_featureMethod · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected