piqa.utils#
Miscellaneous tools and general purpose components
Submodules#
Color space conversion tools |
|
General purpose tensor functionals |
Functions#
Asserts that the types, devices, shapes and values of |
|
Returns whether |
|
Sets and returns whether debugging is enabled or not. |
Descriptions#
- piqa.utils.set_debug(mode=False)#
Sets and returns whether debugging is enabled or not. If
__debug__
isFalse
, this function has not effect.Example
>>> set_debug(False) False
- piqa.utils.broadcastable(*shapes)#
Returns whether
shapes
are broadcastable.Example
>>> x = torch.rand(3, 2, 1) >>> y = torch.rand(1, 2, 3) >>> z = torch.rand(2, 2, 2) >>> broadcastable(x.shape, y.shape) True >>> broadcastable(y.shape, z.shape) False
- piqa.utils.assert_type(*tensors, device=None, dim_range=None, n_channels=None, value_range=None)#
Asserts that the types, devices, shapes and values of
tensors
are valid with respect to some requirements.Example
>>> x = torch.rand(5, 3, 256, 256) >>> y = torch.rand(5, 3, 256, 256) >>> assert_type(x, y, dim_range=(4, 4), n_channels=3)