File size: 199 Bytes
801501a
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
import numpy as np
import torch

def th2np(tensor):
    if isinstance(tensor, np.ndarray):
        return tensor
    if isinstance(tensor, torch.Tensor):
        return tensor.detach().cpu().numpy()