Shortcuts

Source code for rising.utils.checktype

import torch
from typing import Union, Any


[docs]def check_scalar(x: Union[Any, float, int]) -> bool: """ Provide interface to check for scalars Args: x: object to check for scalar Returns: bool" True if input is scalar """ return isinstance(x, (int, float)) or (isinstance(x, torch.Tensor) and x.numel() == 1)

© Copyright Copyright (c) 2019-2020, Justus Schock, Michael Baumgartner.. Revision ca0cf77f.

Read the Docs v: v0.2.1
Versions
latest
stable
v0.2.1
v0.2.0post0
v0.2.0
Downloads
On Read the Docs
Project Home
Builds

Free document hosting provided by Read the Docs.