MCPcopy Create free account
hub / github.com/TorchSSL/TorchSSL / to_numpy

Method to_numpy

custom_writer.py:135–143  ·  view source on GitHub ↗
(self, a)

Source from the content-addressed store, hash-verified

133 return plt
134
135 def to_numpy(self, a):
136 if isinstance(a, list):
137 return np.array(a)
138 for kind in [torch.Tensor, torch.nn.Parameter]:
139 if isinstance(a, kind):
140 if hasattr(a, 'detach'):
141 a = a.detach()
142 return a.cpu().numpy()
143 return a
144
145 def add_scalar(self, tag, data):
146 data = self.to_numpy(data)

Callers 1

add_scalarMethod · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected