Networks
Networks of and helper functions for supported architectures.
Helper functions and networks.
- ecgan.networks.helpers.apply_input_normalization(channel_size, normalization, **kwargs)[source]
Apply input normalization to a layer of size channel_size.
- Parameters
channel_size (
int) -- Size of the channel/layer.normalization (
Optional[InputNormalization]) -- Selected normalization method.kwargs -- Optional parameters which might be required for normalizations.
- Return type
Optional[Module]
- ecgan.networks.helpers.conv1d_block(in_channels, out_channels, k=4, s=2, p=1, bias=False)[source]
Abbreviate the creation of a Conv1d block.
- Parameters
in_channels (
int) -- input channels.out_channels (
int) -- output channels.k (
int) -- kernel size.s (
int) -- stride.p (
int) -- padding.bias (
bool) -- bias.
- Return type
Conv1d- Returns
A Conv1d block.
- ecgan.networks.helpers.conv1d_trans_block(in_channels, out_channels, k=4, s=2, p=1, bias=False)[source]
Abbreviate the creation of a 1d convolutional transpose block.
- Parameters
in_channels (
int) -- input channels.out_channels (
int) -- output channels.k (
int) -- kernel size.s (
int) -- stride.p (
int) -- padding.bias (
bool) -- bias.
- Return type
ConvTranspose1d- Returns
A ConvTranspose1d block.
Generate a downsampling CNN architecture, with LeakyReLU activation and optionally weight/input normalization.
Note
seq_len has to be divisible by 32 for the pooling kernel.
- Parameters
input_channels (
int) -- Amount of input channels.hidden_channels (
List[int]) -- List of hidden channel sizes. Should be of length 5.output_channels (
int) -- Amount of output channels.seq_len (
int) -- Sequence length of the data.input_norm (
InputNormalization) -- Type of input normalization.spectral_norm (
bool) -- Flag to indicate if spectral weight normalization should be performedtrack_running_stats (
bool) -- Flag to indicate if a BatchNorm layer should track the running statistics.
- Return type
Sequential- Returns
A five hidden layer CNN as nn.Module.
- ecgan.networks.helpers.create_transpose_conv_net(input_channels, hidden_channels, output_channels, seq_len, input_norm, spectral_norm=False, track_running_stats=True)[source]
Create a 5 hidden layer conv transposed network.
- Parameters
input_channels (
int) -- Amount of input channels.hidden_channels (
List[int]) -- List of hidden channel sizes. Should be of length 5.output_channels (
int) -- Amount of output channels.seq_len (
int) -- Sequence length of the data.input_norm (
InputNormalization) -- Type of input normalization.spectral_norm (
bool) -- Flag to indicate if spectral weight normalization should be performedtrack_running_stats -- Flag to indicate if a BatchNorm layer should track the running statistics.
- Return type
Sequential- Returns
A five hidden layer transposed CNN as nn.Module.
- ecgan.networks.helpers.conv_norm_relu(input_channels, output_channels, kernel_size, stride=1, padding=0, bias=False)[source]
Chain convolutional layers with ReLU activations and batch norm.
- Return type
Sequential
Generic CNNs.
- class ecgan.networks.cnn.ConvolutionalNeuralNetwork(input_channels, hidden_channels, out_channels, n_classes, seq_len, input_norm)[source]
Bases:
ecgan.utils.configurable.ConfigurableTorchModuleGeneric CNN which can be used for classification.
- class ecgan.networks.cnn.DownsampleCNN(kernel_sizes, pooling_kernel_size, input_channels, output_channels, seq_len, sampling_seq_len)[source]
Bases:
ecgan.utils.configurable.ConfigurableTorchModuleA CNN used for downsampling.
Simple RNN (LSTM) which can be used for classification.
- class ecgan.networks.rnn.RecurrentNeuralNetwork(num_channels, hidden_dim, hidden_size, n_classes)[source]
Bases:
ecgan.utils.configurable.ConfigurableTorchModuleGeneric Recurrent Neural Network classifier with LSTM blocks followed by a fully connected layer.
RGAN architectures for the discriminator and generator.
- class ecgan.networks.rgan.RGANGenerator(input_size, output_size, params)[source]
Bases:
ecgan.utils.configurable.ConfigurableTorchModuleGenerator with the RGAN architecture.
- class ecgan.networks.rgan.RGANDiscriminator(input_size, params)[source]
Bases:
ecgan.utils.configurable.ConfigurableTorchModuleDiscriminator with the RGAN architecture with additional spectral normalization.
Adapted DCGAN generator and discriminator.
- class ecgan.networks.dcgan.DCGANGenerator(input_channels, output_channels, params, seq_len=128)[source]
Bases:
ecgan.utils.configurable.ConfigurableTorchModuleA generator using an architecture similar to Radford et al. 2015.
- class ecgan.networks.dcgan.DCGANDiscriminator(input_channels, params)[source]
Bases:
ecgan.utils.configurable.ConfigurableTorchModuleSlightly modified discriminator from Radford et al. 2015.
BeatGAN encoder, generator and discriminator from Zhou et al. 2019.
- class ecgan.networks.beatgan.BeatganInverseEncoder(input_channels, hidden_channels, output_channels, seq_len, input_norm, spectral_norm)[source]
Bases:
ecgan.utils.configurable.ConfigurableTorchModuleEncoder of the BeatGAN model.
- class ecgan.networks.beatgan.BeatganDiscriminator(input_channels, hidden_channels, output_channels, seq_len, input_norm, spectral_norm)[source]
Bases:
ecgan.utils.configurable.ConfigurableTorchModuleDiscriminator of the BeatGAN model.
- class ecgan.networks.beatgan.BeatganGenerator(input_channels, hidden_channels, latent_size, seq_len, input_norm, spectral_norm, tanh_out)[source]
Bases:
ecgan.utils.configurable.ConfigurableTorchModuleGenerator of the BeatGAN model.
VAEGAN encoder.
- class ecgan.networks.vaegan.VAEEncoder(input_channels, latent_size, hidden_channels, seq_len, spectral_norm=False, input_norm=None, track_running_stats=True)[source]
Bases:
ecgan.utils.configurable.ConfigurableTorchModuleVariational Convolutional Encoder Module.