Utils Functions

Here can be found the implementation of the auxiliary functions for the implementation of the architectures.

TSFEDL.utils.TimeDistributed(module)

TimeDistributed module implementation.

TSFEDL.utils.flip_indices_for_conv_to_lstm(x)

Changes the (N, C, L) dimension to (N, L, C).

TSFEDL.utils.flip_indices_for_conv_to_lstm_reshape(x)

Changes the (N, C, L) dimension to (N, L, C).

TSFEDL.utils.check_inputs(include_top, ...)

Auxiliar function for checking the input parameters of the models.

TSFEDL.utils.full_convolution(x, filters, ...)

It performs a Full convolution operation on the given keras Tensor.

TSFEDL.utils.TimeDistributed(module)[source]

TimeDistributed module implementation.

TSFEDL.utils.flip_indices_for_conv_to_lstm(x: Tensor) Tensor[source]

Changes the (N, C, L) dimension to (N, L, C). This is due to features in PyTorch’s LSTMs are expected on the last dim.

Parameters:

x (torch.Tensor) – Input tensor.

Returns:

x – Output tensor.

Return type:

torch.Tensor

TSFEDL.utils.flip_indices_for_conv_to_lstm_reshape(x: Tensor) Tensor[source]

Changes the (N, C, L) dimension to (N, L, C). This is due to features in PyTorch’s LSTMs are expected on the last dim.

Parameters:

x (torch.Tensor) – Input tensor.

Returns:

x – Output tensor.

Return type:

torch.Tensor

TSFEDL.utils.check_inputs(include_top, weights, input_tensor, input_shape, classes, classifier_activation)[source]

Auxiliar function for checking the input parameters of the models.

Parameters:
  • include_top (bool) – Boolean value to control if the classification module should be placed in the model.

  • weights (str) – Route to the saved weight of the model.

  • input_tensor (keras.Tensor) – Input tensor of the model.

  • input_shape (tuple) – Tuple with the input shape of the model.

  • classes (int) – Number of classes to predict with the model.

  • classifier_activation (str) – “softmax” or None

Returns:

inp – Input tensor.

Return type:

Keras.Tensor

TSFEDL.utils.full_convolution(x, filters, kernel_size, **kwargs)[source]

It performs a Full convolution operation on the given keras Tensor.

Parameters:
  • x (Keras.Tensor) – Input tensor of the full convolution.

  • filters (int) – Number of filters of the full convolution.

  • kernel_size (int) – Kernel size of the convolution.

  • kwargs (dict) – Rest of the arguments, optional.

Returns:

x – Output tensor.

Return type:

Keras.Tensor