elektronn3.data.utils module

class elektronn3.data.utils.CleanExit[source]

Bases: object

class elektronn3.data.utils.DelayedInterrupt(signals)[source]

Bases: object

class elektronn3.data.utils.GracefulInterrupt[source]

Bases: object

exit_gracefully(sig, frame)[source]
now = False
elektronn3.data.utils.as_floatX(x)[source]
elektronn3.data.utils.calculate_class_weights(targets, mode='inverse')[source]

Calulate class weights that assign more weight to less common classes.

The weights can then be used for loss function rebalancing (e.g. for CrossEntropyLoss it’s very important to do this when training on datasets with high class imbalance.

Return type

ndarray

elektronn3.data.utils.calculate_means(inputs)[source]
Return type

Tuple[float]

elektronn3.data.utils.calculate_nd_slice(src, coords_lo, coords_hi)[source]

Calculate the slice object list that is used as indices for reading from a data source.

Unfortunately, this kind of slice list is not yet supported by h5py. It only works with numpy arrays.

elektronn3.data.utils.calculate_stds(inputs)[source]
Return type

Tuple[float]

elektronn3.data.utils.save_to_h5(data, path, hdf5_names=None, overwrite=False, compression=True)[source]

Saves data to HDF5 File.

Parameters
  • data (list or dict of np.arrays) – if list, hdf5_names has to be set.

  • path (str) – forward-slash separated path to file

  • hdf5_names (list of str) – has to be the same length as data

  • overwrite (bool) – determines whether existing files are overwritten

  • compression (bool) – True: compression=’gzip’ is used which is recommended for sparse and ordered data

Returns

Return type

nothing

elektronn3.data.utils.squash01(img)[source]

Squash image array to the value range [0, 1] (no clipping).

This can be used to prepare network outputs or normalized inputs for plotting and generic image processing functions.

Return type

ndarray