plenoptic.validate.validate_input#
- plenoptic.validate.validate_input(input_tensor, no_batch=False)[source]#
Determine whether
input_tensorcan be used for synthesis.In particular, this function:
Checks if input_tensor has a float or complex dtype (
TypeError).If
no_batchisTrue, check whetherinput_tensor.shape[0] == 1orinput_tensor.ndimension()==1(ValueError).
Additionally, if input_tensor is not 4d, or of it is outside the range (0, 1), raises a
UserWarning.- Parameters:
- Raises:
ValueError – If
no_batchisTrueand the batch dimension ofinput_tensoris greater than 1.TypeError – If
input_tensordoes not have a float or complex dtype.
- Warns:
UserWarning – If
input_tensoris not 4dUserWarning – If
input_tensorhas values outside (0, 1).
Examples
Check that our built-in images work:
>>> import plenoptic as po >>> po.validate.validate_input(po.data.einstein())
Intentionally fail:
>>> import plenoptic as po >>> img = torch.randint(low=0, high=255, size=(1, 1, 32, 32)) >>> po.validate.validate_input(img) Traceback (most recent call last): TypeError: Only float or complex dtypes are allowed ...