If the type of value is torch.Tensor, convert the value to np.ndarray. Args: value (np.ndarray, torch.Tensor): value. Returns: Any: value.
(value: Union[np.ndarray, torch.Tensor])
| 11 | |
| 12 | |
| 13 | def tensor2ndarray(value: Union[np.ndarray, torch.Tensor]) -> np.ndarray: |
| 14 | """If the type of value is torch.Tensor, convert the value to np.ndarray. |
| 15 | |
| 16 | Args: |
| 17 | value (np.ndarray, torch.Tensor): value. |
| 18 | |
| 19 | Returns: |
| 20 | Any: value. |
| 21 | """ |
| 22 | if isinstance(value, torch.Tensor): |
| 23 | value = value.detach().cpu().numpy() |
| 24 | return value |
| 25 | |
| 26 | |
| 27 | def value2list(value: Any, valid_type: Union[Type, Tuple[Type, ...]], |
no test coverage detected
searching dependent graphs…