core.nn.enets.create_enet_with_projection_layer_and_dense_resnet
core.nn.enets.create_enet_with_projection_layer_and_dense_resnet(
input_dims,
V_rb_list,
output_dim,
hidden_dims,
svd,
activation='elu',
dropout=0.0,
batch_norm=True,
added_context=False,
)Builder function for 2-stage embedding network for 1D data with multiple blocks and channels. Module 1 is a linear layer initialized as the projection of the complex signal onto reduced basis components via the LinearProjectionRB, where the blocks are kept separate. See docstring of LinearProjectionRB for details. Module 2 is a sequence of dense residual layers, that is used to further reduce the dimensionality.
The projection requires the complex signal to be represented via the real part in channel 0 and the imaginary part in channel 1. Auxiliary signals may be contained in channels with indices => 2. In GW use case a block corresponds to a detector and channel 2 is used for ASD information.
If added_context = True, the 2-stage embedding network described above is merged with an identity mapping via ModuleMerger. Then, the expected input is not x with x.shape = (batch_size, num_blocks, num_channels, num_bins), but rather the tuple *(x, z), where z is additional context information. The output of the full module is then the concatenation of enet(x) and z. In GW use case, this is used to concatenate the applied time shifts z to the embedded feature vector of the strain data enet(x).
Module specs
For added_context == False: input dimension: (batch_size, num_blocks, num_channels, num_bins) output dimension: (batch_size, output_dim) For added_context == True: input dimension: (batch_size, num_blocks, num_channels, num_bins), (batch_size, N) output dimension: (batch_size, output_dim + N)
:param input_dims: list dimensions of input batch, omitting batch dimension input_dims = (num_blocks, num_channels, num_bins) :param n_rb: int number of reduced basis elements used for projection the output dimension of the layer is 2 * n_rb * num_blocks :param V_rb_list: tuple of np.arrays, or None tuple with V matrices of the reduced basis SVD projection, convention for SVD matrix decomposition: U @ s @ V^h; if None, layer is not initialized with reduced basis projection, this is useful when loading a saved model :param output_dim: int output dimension of the full module :param hidden_dims: tuple tuple with dimensions of hidden layers of module 2 :param activation: str str that specifies activation function used in residual blocks :param dropout: float dropout probability for residual blocks used for reqularization :param batch_norm: bool flag that specifies whether to use batch normalization :param added_context: bool if set to True, additional context z is concatenated to the embedded feature vector enet(x); note that in this case, the expected input is a tuple with 2 elements, input = (x, z) rather than just the tensor x. :return: nn.Module