brails.processors.foundation_classifier.attention_utils.utils module

brails.processors.foundation_classifier.attention_utils.utils.construct_confusion_matrix_image(classes, con_mat)
brails.processors.foundation_classifier.attention_utils.utils.evaluate(summary_writer, mode_name, y_gt, y_pred, avg_loss, classes, epoch)
brails.processors.foundation_classifier.attention_utils.utils.sliding_window(data, size, stepsize=1, padded=False, axis=-1, copy=True)

Calculate a sliding window over a signal :param data: The array to be slided over. :type data: numpy array :param size: The sliding window size :type size: int :param stepsize: The sliding window stepsize. Defaults to 1. :type stepsize: int :param axis: The axis to slide over. Defaults to the last axis. :type axis: int :param copy: Return strided array as copy to avoid sideffects when manipulating the

output array.

Returns:

data – A matrix where row in last dimension consists of one instance of the sliding window.

Return type:

numpy array

Notes

  • Be wary of setting copy to False as undesired sideffects with the output values may occur.

Examples

>>> a = numpy.array([1, 2, 3, 4, 5])
>>> sliding_window(a, size=3)
array([[1, 2, 3],
       [2, 3, 4],
       [3, 4, 5]])
>>> sliding_window(a, size=3, stepsize=2)
array([[1, 2, 3],
       [3, 4, 5]])

See also

pieces

Calculate number of pieces available by sliding