carpet/checks.py
def check_tensor(*arrays, device=None, dtype=torch.float64,
                 requires_grad=None):
    """Take input arrays and return tensors with float64 type, on the
    specified device and with requires_grad correctly set.

    Parameters
    ----------
    arrays: ndarray or Tensor or float
        Input arrays to convert to torch.Tensor.
    device: str or None (default: None)
        Device on which the tensor are created.
    requires_grad: bool or None (default: None)
        If requires_grad is passed, the corresponding flag is set in the
        output Tensors.
    """

    n_arrays = len(arrays)
    result = []
    for x in arrays:
        initial_type = type(x)
        if isinstance(x, np.ndarray) or isinstance(x, numbers.Number):
            x = torch.tensor(x)
        assert isinstance(x, torch.Tensor), (
            f"Invalid type {initial_type} in check_tensor. "
            "Should be in {'ndarray, int, float, Tensor'}."
        )
        x = x.to(device=device, dtype=dtype)
        if requires_grad is not None:
            x.requires_grad_(requires_grad)
        result.append(x)

    return tuple(result) if n_arrays > 1 else result[0]
Take input arrays and return tensors with float64 type, on the
    specified device and with requires_grad correctly set.

    Parameters
    ----------
    arrays: ndarray or Tensor or float
        Input arrays to convert to torch.Tensor.
    device: str or None (default: None)
        Device on which the tensor are created.
    requires_grad: bool or None (default: None)
        If requires_grad is passed, the corresponding flag is set in the
        output Tensors.
    
Take input arrays and return tensors with float64 type, on the
specified device and with requires_grad correctly set.

Parameters

ndarray or Tensor or float
Input arrays to convert to torch.Tensor.
device: str or None (default: None)
Device on which the tensor are created.
requires_grad: bool or None (default: None)
If requires_grad is passed, the corresponding flag is set in the
output Tensors.
Take input arrays and return tensors with float64 type on the specified device and with requires_grad correctly set . Parameters ndarray or Tensor or float Input arrays to convert to torch . Tensor . device : str or None ( default : None ) Device on which the tensor are created . requires_grad : bool or None ( default : None ) If requires_grad is passed the corresponding flag is set in the output Tensors .
def check_tensor(*arrays, device=None, dtype=torch.float64,
                 requires_grad=None):
    n_arrays = len(arrays)
    result = []
    for x in arrays:
        initial_type = type(x)
        if isinstance(x, np.ndarray) or isinstance(x, numbers.Number):
            x = torch.tensor(x)
        assert isinstance(x, torch.Tensor), (
            f"Invalid type {initial_type} in check_tensor. "
            "Should be in {'ndarray, int, float, Tensor'}."
        )
        x = x.to(device=device, dtype=dtype)
        if requires_grad is not None:
            x.requires_grad_(requires_grad)
        result.append(x)
    return tuple(result) if n_arrays > 1 else result[0]
def check_tensor ( * arrays , device = None , dtype = torch . float64 , requires_grad = None ) : n_arrays = len ( arrays ) result = [ ] for x in arrays : initial_type = type ( x ) if isinstance ( x , np . ndarray ) or isinstance ( x , numbers . Number ) : x = torch . tensor ( x ) assert isinstance ( x , torch . Tensor ) , ( f"Invalid type {initial_type} in check_tensor. " "Should be in {'ndarray, int, float, Tensor'}." ) x = x . to ( device = device , dtype = dtype ) if requires_grad is not None : x . requires_grad_ ( requires_grad ) result . append ( x ) return tuple ( result ) if n_arrays > 1 else result [ 0 ]
Take input arrays and return tensors with float64 type, on the
specified device and with requires_grad correctly set.
Take input arrays and return tensors with float64 type on the specified device and with requires_grad correctly set .
"""Take input arrays and return tensors with float64 type, on the
    specified device and with requires_grad correctly set.

    Parameters
    ----------
    arrays: ndarray or Tensor or float
        Input arrays to convert to torch.Tensor.
    device: str or None (default: None)
        Device on which the tensor are created.
    requires_grad: bool or None (default: None)
        If requires_grad is passed, the corresponding flag is set in the
        output Tensors.
    """
device
dtype
requires_grad