Global - > Utils Functions

Device

tardis_em.utils.device.get_device(device: str = '0') device

Return a device that can be used for training or predictions

Parameters:

device (str, int) – Device name or ID.

Returns:

Device type.

Return type:

torch.device

tardis_em.utils.device.device_is_str(device: str = '0') bool

Check if used device is convertible to int value

Parameters:

device (str, int) – Device ID.

Returns:

Check for input string/int

Return type:

bool

Global Utils

tardis_em.utils.utils.get_n_params(model)
class tardis_em.utils.utils.EarlyStopping(patience=10, min_delta=0)

Early stopping to stop the training when the loss does not improve after certain epochs.

Parameters:
  • patience (int) – how many epochs to wait before stopping when loss is not improving.

  • min_delta (int) – minimum difference between new loss and old loss for new loss to be considered as an improvement.

tardis_em.utils.utils.check_uint8(image: ndarray)

Simple check for uint8 array.

If array is not compliant, then data are examine for a type of data (binary mask, image with int8 etc.) and converted back to uint8.

Parameters:

image (np.ndarray) – Image for evaluation.