Creates tensors cloning a numpy array, with the given precision (defaulting to input's precision) and the given device (in case of GPUs)
(self, *arrays, type_as=None)
| 272 | |
| 273 | # convert batch of arrays from numpy |
| 274 | def from_numpy(self, *arrays, type_as=None): |
| 275 | """Creates tensors cloning a numpy array, with the given precision (defaulting to input's precision) and the given device (in case of GPUs)""" |
| 276 | if len(arrays) == 1: |
| 277 | return self._from_numpy(arrays[0], type_as=type_as) |
| 278 | else: |
| 279 | return [self._from_numpy(array, type_as=type_as) for array in arrays] |
| 280 | |
| 281 | # convert an array from numpy |
| 282 | def _from_numpy(self, a, type_as=None): |