brails.processors.FoundationClassifier.attention_utils.utils module

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

Calculate a sliding window over a signal Parameters ———- data : numpy array

The array to be slided over.

sizeint

The sliding window size

stepsizeint

The sliding window stepsize. Defaults to 1.

axisint

The axis to slide over. Defaults to the last axis.

copybool

Return strided array as copy to avoid sideffects when manipulating the output array.

Returns

datanumpy array

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

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