das.models

Defines the network architectures.

das.models.cnn(nb_freq, nb_classes, nb_channels=1, nb_hist=1, nb_filters=16, nb_stacks=2, kernel_size=3, nb_conv=3, loss='categorical_crossentropy', batch_norm=False, return_sequences=False, sample_weight_mode: Optional[str] = None, learning_rate: float = 0.0001, **kwignored)[source]

CNN for single-frequency and multi-channel data - uses 1D convolutions.

Parameters
  • nb_freq ([type]) – [description]

  • nb_classes ([type]) – [description]

  • nb_channels (int, optional) – [description]. Defaults to 1.

  • nb_hist (int, optional) – [description]. Defaults to 1.

  • nb_filters (int, optional) – [description]. Defaults to 16.

  • nb_stacks (int, optional) – [description]. Defaults to 2.

  • kernel_size (int, optional) – [description]. Defaults to 3.

  • nb_conv (int, optional) – [description]. Defaults to 3.

  • loss (str, optional) – [description]. Defaults to “categorical_crossentropy”.

  • batch_norm (bool, optional) – [description]. Defaults to False.

  • return_sequences (bool, optional) – [description]. Defaults to False.

  • kwignored (Dict, optional) – additional kw args in the param dict used for calling m(**params) to be ingonred

Raises

ValueError – When trying to init model with return_sequences. The cnn only does instance classificaton, not regression (sequence prediction).

Returns

[description]

Return type

[type]

das.models.cnn2D(nb_freq, nb_classes, nb_channels=1, nb_hist=1, nb_filters=16, nb_stacks=2, kernel_size=3, nb_conv=3, loss='categorical_crossentropy', batch_norm=False, return_sequences=False, sample_weight_mode: Optional[str] = None, learning_rate: float = 0.0001, **kwignored)[source]

CNN for multi-frequency and multi-channel data - uses 2D convolutions.

Parameters
  • nb_freq ([type]) – [description]

  • nb_classes ([type]) – [description]

  • nb_channels (int, optional) – [description]. Defaults to 1.

  • nb_hist (int, optional) – [description]. Defaults to 1.

  • nb_filters (int, optional) – [description]. Defaults to 16.

  • nb_stacks (int, optional) – [description]. Defaults to 2.

  • kernel_size (int, optional) – [description]. Defaults to 3.

  • nb_conv (int, optional) – [description]. Defaults to 3.

  • loss (str, optional) – [description]. Defaults to “categorical_crossentropy”.

  • batch_norm (bool, optional) – [description]. Defaults to False.

  • return_sequences (bool, optional) – [description]. Defaults to False.

  • kwignored (Dict, optional) – additional kw args in the param dict used for calling m(**params) to be ingonred

Raises

ValueError – When trying to init model with return_sequences. The cnn only does instance classificaton, not regression (sequence prediction).

Returns

[description]

Return type

[type]

das.models.fcn(nb_freq, nb_classes, nb_channels=1, nb_hist=1, nb_filters=16, nb_stacks=2, kernel_size=3, nb_conv=3, loss='categorical_crossentropy', batch_norm=False, return_sequences=True, sample_weight_mode: Optional[str] = None, learning_rate: float = 0.0001, **kwignored)[source]

[summary]

Parameters
  • nb_freq ([type]) – [description]

  • nb_classes ([type]) – [description]

  • nb_channels (int, optional) – [description]. Defaults to 1.

  • nb_hist (int, optional) – [description]. Defaults to 1.

  • nb_filters (int, optional) – [description]. Defaults to 16.

  • nb_stacks (int, optional) – [description]. Defaults to 2.

  • kernel_size (int, optional) – [description]. Defaults to 3.

  • nb_conv (int, optional) – [description]. Defaults to 3.

  • loss (str, optional) – [description]. Defaults to “categorical_crossentropy”.

  • batch_norm (bool, optional) – [description]. Defaults to False.

  • return_sequences (bool, optional) – [description]. Defaults to True.

  • kwignored (Dict, optional) – additional kw args in the param dict used for calling m(**params) to be ingonred

Returns

[description]

Return type

[type]

das.models.fcn2D(nb_freq, nb_classes, nb_channels=1, nb_hist=1, nb_filters=16, nb_stacks=2, kernel_size=3, nb_conv=3, loss='categorical_crossentropy', batch_norm=False, return_sequences=True, sample_weight_mode: Optional[str] = None, learning_rate: float = 0.0005, **kwignored)[source]

[summary]

Parameters
  • nb_freq ([type]) – [description]

  • nb_classes ([type]) – [description]

  • nb_channels (int, optional) – [description]. Defaults to 1.

  • nb_hist (int, optional) – [description]. Defaults to 1.

  • nb_filters (int, optional) – [description]. Defaults to 16.

  • nb_stacks (int, optional) – [description]. Defaults to 2.

  • kernel_size (int, optional) – [description]. Defaults to 3.

  • nb_conv (int, optional) – [description]. Defaults to 3.

  • loss (str, optional) – [description]. Defaults to “categorical_crossentropy”.

  • batch_norm (bool, optional) – [description]. Defaults to False.

  • return_sequences (bool, optional) – [description]. Defaults to True.

  • kwignored (Dict, optional) – additional kw args in the param dict used for calling m(**params) to be ingonred

Returns

[description]

Return type

[type]

das.models.tcn(*args, **kwargs)[source]

Synonym for tcn_seq.

das.models.tcn_multi(nb_freq: int, nb_classes: int, nb_hist: int = 1, nb_filters: int = 16, kernel_size: int = 3, nb_conv: int = 1, loss: str = 'categorical_crossentropy', dilations: List[int] = [1, 2, 4, 8, 16], activation: str = 'norm_relu', use_skip_connections: bool = True, return_sequences: bool = True, dropout_rate: float = 0.0, padding: str = 'same', sample_weight_mode: Optional[str] = None, learning_rate: float = 0.0005, use_separable: bool = False, pre_kernel_size: int = 16, pre_nb_filters: int = 16, pre_nb_conv: int = 2, **kwignored)[source]

Create TCN network with TCN layer as pre-processing and downsampling frontend with weights shared between channels.

Parameters
  • nb_freq (int) – [description]

  • nb_classes (int) – [description]

  • nb_hist (int, optional) – [description]. Defaults to 1.

  • nb_filters (int, optional) – [description]. Defaults to 16.

  • kernel_size (int, optional) – [description]. Defaults to 3.

  • nb_conv (int, optional) – [description]. Defaults to 1.

  • loss (str, optional) – [description]. Defaults to “categorical_crossentropy”.

  • dilations (List[int], optional) – [description]. Defaults to [1, 2, 4, 8, 16].

  • activation (str, optional) – [description]. Defaults to ‘norm_relu’.

  • use_skip_connections (bool, optional) – [description]. Defaults to True.

  • return_sequences (bool, optional) – [description]. Defaults to True.

  • dropout_rate (float, optional) – [description]. Defaults to 0.00.

  • padding (str, optional) – [description]. Defaults to ‘same’.

  • learning_rate (float, optional) –

  • use_separable (bool, optional) – use separable convs in residual block. Defaults to False.

  • nb_pre_conv (int, optional) – If >0 adds a single STFT layer with a hop size of 2**nb_pre_conv before the TCN. Useful for speeding up training by reducing the sample rate early in the network. Defaults to 0 (no downsampling)

  • pre_nb_filters

  • pre_kernelsize

  • pre_nb_conv

  • kwignored (Dict, optional) – additional kw args in the param dict used for calling m(**params) to be ingonred

Returns

Compiled TCN network model.

Return type

[keras.models.Model]

das.models.tcn_seq(nb_freq: int, nb_classes: int, nb_hist: int = 1, nb_filters: int = 16, kernel_size: int = 3, nb_conv: int = 1, loss: str = 'categorical_crossentropy', dilations: List[int] = [1, 2, 4, 8, 16], activation: str = 'norm_relu', use_skip_connections: bool = True, return_sequences: bool = True, dropout_rate: float = 0.0, padding: str = 'same', sample_weight_mode: Optional[str] = None, nb_pre_conv: int = 0, learning_rate: float = 0.0001, out_activation: str = 'softmax', use_separable: bool = False, **kwignored)[source]

Create TCN network.

Parameters
  • nb_freq (int) – [description]

  • nb_classes (int) – [description]

  • nb_hist (int, optional) – [description]. Defaults to 1.

  • nb_filters (int, optional) – [description]. Defaults to 16.

  • kernel_size (int, optional) – [description]. Defaults to 3.

  • nb_conv (int, optional) – [description]. Defaults to 1.

  • loss (str, optional) – [description]. Defaults to “categorical_crossentropy”.

  • dilations (List[int], optional) – [description]. Defaults to [1, 2, 4, 8, 16].

  • activation (str, optional) – [description]. Defaults to ‘norm_relu’.

  • use_skip_connections (bool, optional) – [description]. Defaults to True.

  • return_sequences (bool, optional) – [description]. Defaults to True.

  • dropout_rate (float, optional) – [description]. Defaults to 0.00.

  • padding (str, optional) – [description]. Defaults to ‘same’.

  • nb_pre_conv (int, optional) – number of conv-relu-batchnorm-maxpool2 blocks before the TCN - useful for reducing the sample rate. Defaults to 0

  • out_activation (str, optional) – activation type for the output. Defaults to ‘softmax’.

  • use_separable (bool, optional) – use separable convs in residual block. Defaults to False.

  • kwignored (Dict, optional) – additional kw args in the param dict used for calling m(**params) to be ignored

Returns

Compiled TCN network model.

Return type

[keras.models.Model]

das.models.tcn_small(nb_freq: int, nb_classes: int, nb_hist: int = 1, nb_filters: int = 16, kernel_size: int = 3, nb_conv: int = 1, loss: str = 'categorical_crossentropy', dilations: List[int] = [1, 2, 4, 8, 16], activation: str = 'norm_relu', use_skip_connections: bool = True, return_sequences: bool = True, dropout_rate: float = 0.0, padding: str = 'same', sample_weight_mode: Optional[str] = None, nb_pre_conv: int = 0, learning_rate: float = 0.0005, upsample: bool = True, use_separable: bool = False, **kwignored)[source]

Create TCN network with TCN layer as pre-processing and downsampling frontend.

Parameters
  • nb_freq (int) – [description]

  • nb_classes (int) – [description]

  • nb_hist (int, optional) – [description]. Defaults to 1.

  • nb_filters (int, optional) – [description]. Defaults to 16.

  • kernel_size (int, optional) – [description]. Defaults to 3.

  • nb_conv (int, optional) – [description]. Defaults to 1.

  • loss (str, optional) – [description]. Defaults to “categorical_crossentropy”.

  • dilations (List[int], optional) – [description]. Defaults to [1, 2, 4, 8, 16].

  • activation (str, optional) – [description]. Defaults to ‘norm_relu’.

  • use_skip_connections (bool, optional) – [description]. Defaults to True.

  • return_sequences (bool, optional) – [description]. Defaults to True.

  • dropout_rate (float, optional) – [description]. Defaults to 0.00.

  • padding (str, optional) – [description]. Defaults to ‘same’.

  • nb_pre_conv (int, optional) – If >0 adds a single TCN layer with a final maxpooling layer with block size of 2**nb_pre_conv before the TCN. Useful for speeding up training by reducing the sample rate early in the network. Defaults to 0 (no downsampling)

  • learning_rate (float, optional) –

  • upsample (bool, optional) – whether or not to restore the model output to the input samplerate. Should generally be True during training and evaluation but my speed up inference . Defaults to True.

  • use_separable (bool, optional) – use separable convs in residual block. Defaults to False.

  • kwignored (Dict, optional) – additional kw args in the param dict used for calling m(**params) to be ingonred

Returns

Compiled TCN network model.

Return type

[keras.models.Model]

das.models.tcn_stft(nb_freq: int, nb_classes: int, nb_hist: int = 1, nb_filters: int = 16, kernel_size: int = 3, nb_conv: int = 1, loss: str = 'categorical_crossentropy', dilations: List[int] = [1, 2, 4, 8, 16], activation: str = 'norm_relu', use_skip_connections: bool = True, return_sequences: bool = True, dropout_rate: float = 0.0, padding: str = 'same', sample_weight_mode: Optional[str] = None, nb_pre_conv: int = 0, pre_nb_dft: int = 64, nb_lstm_units: int = 0, learning_rate: float = 0.0005, upsample: bool = True, use_separable: bool = False, **kwignored)[source]

Create TCN network with optional trainable STFT layer as pre-processing and downsampling frontend.

Parameters
  • nb_freq (int) – [description]

  • nb_classes (int) – [description]

  • nb_hist (int, optional) – [description]. Defaults to 1.

  • nb_filters (int, optional) – [description]. Defaults to 16.

  • kernel_size (int, optional) – [description]. Defaults to 3.

  • nb_conv (int, optional) – [description]. Defaults to 1.

  • loss (str, optional) – [description]. Defaults to “categorical_crossentropy”.

  • dilations (List[int], optional) – [description]. Defaults to [1, 2, 4, 8, 16].

  • activation (str, optional) – [description]. Defaults to ‘norm_relu’.

  • use_skip_connections (bool, optional) – [description]. Defaults to True.

  • return_sequences (bool, optional) – [description]. Defaults to True.

  • dropout_rate (float, optional) – [description]. Defaults to 0.00.

  • padding (str, optional) – [description]. Defaults to ‘same’.

  • nb_pre_conv (int, optional) – If >0 adds a single STFT layer with a hop size of 2**nb_pre_conv before the TCN. Useful for speeding up training by reducing the sample rate early in the network. Defaults to 0 (no downsampling)

  • pre_nb_dft (int, optional) – Number of filters (roughly corresponding to filters) in the STFT frontend. Defaults to 64.

  • learning_rate (float, optional) –

  • nb_lstm_units (int, optional) – Defaults to 0.

  • upsample (bool, optional) – whether or not to restore the model output to the input samplerate. Should generally be True during training and evaluation but my speed up inference. Defaults to True.

  • use_separable (bool, optional) – use separable convs in residual block. Defaults to False.

  • kwignored (Dict, optional) – additional kw args in the param dict used for calling m(**params) to be ingonred

Returns

Compiled TCN network model.

Return type

[keras.models.Model]

das.models.tcn_tcn(nb_freq: int, nb_classes: int, nb_hist: int = 1, nb_filters: int = 16, kernel_size: int = 3, nb_conv: int = 1, loss: str = 'categorical_crossentropy', dilations: List[int] = [1, 2, 4, 8, 16], activation: str = 'norm_relu', use_skip_connections: bool = True, return_sequences: bool = True, dropout_rate: float = 0.0, padding: str = 'same', sample_weight_mode: Optional[str] = None, nb_pre_conv: int = 0, learning_rate: float = 0.0005, upsample: bool = True, use_separable: bool = False, **kwignored)[source]

Create TCN network with TCN layer as pre-processing and downsampling frontend.

Parameters
  • nb_freq (int) – [description]

  • nb_classes (int) – [description]

  • nb_hist (int, optional) – [description]. Defaults to 1.

  • nb_filters (int, optional) – [description]. Defaults to 16.

  • kernel_size (int, optional) – [description]. Defaults to 3.

  • nb_conv (int, optional) – [description]. Defaults to 1.

  • loss (str, optional) – [description]. Defaults to “categorical_crossentropy”.

  • dilations (List[int], optional) – [description]. Defaults to [1, 2, 4, 8, 16].

  • activation (str, optional) – [description]. Defaults to ‘norm_relu’.

  • use_skip_connections (bool, optional) – [description]. Defaults to True.

  • return_sequences (bool, optional) – [description]. Defaults to True.

  • dropout_rate (float, optional) – [description]. Defaults to 0.00.

  • padding (str, optional) – [description]. Defaults to ‘same’.

  • nb_pre_conv (int, optional) – If >0 adds a single TCN layer with a final maxpooling layer with block size of 2**nb_pre_conv before the TCN. Useful for speeding up training by reducing the sample rate early in the network. Defaults to 0 (no downsampling)

  • learning_rate (float, optional) –

  • upsample (bool, optional) – whether or not to restore the model output to the input samplerate. Should generally be True during training and evaluation but my speed up inference . Defaults to True.

  • use_separable (bool, optional) – use separable convs in residual block. Defaults to False.

  • kwignored (Dict, optional) – additional kw args in the param dict used for calling m(**params) to be ingonred

Returns

Compiled TCN network model.

Return type

[keras.models.Model]