minerva.models.nets.lfr_har_architectures

Classes

HARSCnnEncoder

A convolutional encoder used with the LFR technique, adapted from

LFR_HAR_Predictor

A predictor module for LFR in HAR tasks that maps latent embeddings to a randomly

LFR_HAR_Predictor_List

A repeated list of predictor modules for LFR in HAR tasks. Each predictor maps latent

LFR_HAR_Projector

A projector module for LFR in HAR tasks that projects the input data into a random

LFR_HAR_Projector_List

A repeated list of projector modules for LFR in HAR tasks. Each one projects the

Module Contents

class minerva.models.nets.lfr_har_architectures.HARSCnnEncoder(dim=128, input_channel=9, inner_conv_output_dim=128 * 18, permute=False)[source]

Bases: torch.nn.Module

A convolutional encoder used with the LFR technique, adapted from https://github.com/layer6ai-labs/lfr/blob/main/ssl_models/models/encoders.py to work with our HAR dataset.

Parameters

dimint

The dimension of the latent space, by default 128.

input_channelint

The number of input channels, by default 9. In the LFR paper, the shape of the input data was (batch, 9, 128), which required an input_channel value of 9. However, for data in the shape (batch, 6, 60), a value of 6 is required.

inner_conv_output_dimint

The output dimension of the inner convolutional layers, by default 128*18. In the LFR paper, the shape of the input data was (batch, 9, 128), which required an inner_conv_output_dim value of 128*18. However, for data in the shape (batch, 6, 60), a value of 128*10 is required.

conv
forward(xb)[source]
permute = False
Parameters:
  • dim (int)

  • input_channel (int)

  • inner_conv_output_dim (int)

  • permute (bool)

class minerva.models.nets.lfr_har_architectures.LFR_HAR_Predictor(encoding_size, middle_dim, num_layers)[source]

Bases: torch.nn.Module

A predictor module for LFR in HAR tasks that maps latent embeddings to a randomly projected data representation.

Initializes a predictor module.

Parameters

encoding_size: int

The input and output dimensionality of the predictor module.

middle_dim: int

Dimensionality of the hidden layers in the predictor.

num_layers: int

Number of layers in the predictor. If set to 1, the predictor becomes a single linear layer and ‘middle_dim’ is ignored.

forward(z)[source]
Parameters:
  • encoding_size (int)

  • middle_dim (int)

  • num_layers (int)

class minerva.models.nets.lfr_har_architectures.LFR_HAR_Predictor_List(size, encoding_size, middle_dim, num_layers)[source]

Bases: minerva.models.ssl.lfr.RepeatedModuleList

A repeated list of predictor modules for LFR in HAR tasks. Each predictor maps latent embeddings to a randomly projected data representation.

Initializes a list of predictor modules.

Parameters

size: int

Number of predictor modules to instantiate in the list.

encoding_size: int

The input and output dimensionality of each predictor module.

middle_dim: int

Dimensionality of the hidden layers in each predictor.

num_layers: int

Number of layers in each predictor. If set to 1, the predictors become single linear layers and ‘middle_dim’ is ignored.

Parameters:
  • size (int)

  • encoding_size (int)

  • middle_dim (int)

  • num_layers (int)

class minerva.models.nets.lfr_har_architectures.LFR_HAR_Projector(encoding_size=512, input_channel=9, middle_dim=1088)[source]

Bases: torch.nn.Module

A projector module for LFR in HAR tasks that projects the input data into a random latent space.

Initializes a projector module.

Parameters

encoding_size: int

The output dimensionality of the projector module.

input_channel: int

The number of channels in the input data.

middle_dim: int

The expected dimensionality after the convolution module, by default 1088. The original paper, where the input has 9 channels and 128 timestamps, requires 1088. For data with 6 channels and 60 timestamps, 544 should be used.

conv
forward(x)[source]
mlp
Parameters:
  • encoding_size (int)

  • input_channel (int)

  • middle_dim (int)

class minerva.models.nets.lfr_har_architectures.LFR_HAR_Projector_List(size, encoding_size, input_channel, middle_dim)[source]

Bases: minerva.models.ssl.lfr.RepeatedModuleList

A repeated list of projector modules for LFR in HAR tasks. Each one projects the input data into a random latent space.

Initializes a list of projector modules.

Parameters

size: int

Number of projector modules to instantiate in the list.

encoding_size: int

The output dimensionality of each projector module.

input_channel: int

The number of channels in the input data.

Parameters:
  • size (int)

  • encoding_size (int)

  • input_channel (int)

  • middle_dim (int)