ADFWI.dip.model
ADFWI.dip.model.CNN
- class ADFWI.dip.model.CNN.CNN(model_shape, in_channels=[8, 32, 16], vmin=None, vmax=None, dropout_prob=0, random_state_num=100, unit=1000, device='cpu')[source]
Bases:
Module
Initialize the CNN model with the given parameters.
- Parameters:
model_shape (tuple) – The shape of the velocity model, given as (height, width).
in_channels (list of int, optional) – The input and output channels for each CNN block. Default is [8, 32, 16].
vmin (float, optional) – The minimum velocity of the output. Default is None.
vmax (float, optional) – The maximum velocity of the output. Default is None.
dropout_prob (float, optional) – Probability for dropout in CNN layers. Default is 0.
random_state_num (int, optional) – The number of random features for the fully connected input layer. Default is 100.
unit (int, optional) – The scaling factor for the output. Default is 1000.
device (str, optional) – Device to use for computation, either ‘cpu’ or ‘cuda’. Default is ‘cpu’.
- forward()[source]
Forward pass through the network.
- Returns:
The output of the CNN model after processing, reshaped and scaled with the given vmin and vmax.
- Return type:
torch.Tensor
- training: bool
ADFWI.dip.model.MLP
- class ADFWI.dip.model.MLP.MLP(model_shape, random_state_num=100, hidden_layer_number=[100, 100], vmin=None, vmax=None, unit=1000, device='cpu')[source]
Bases:
Module
A Multi-layer Perceptron (MLP) model for generating velocity models.
- Parameters:
model_shape (tuple) – The shape of the velocity model, given as (height, width).
random_state_num (int, optional) – The number of random features for the fully connected input layer. Default is 100.
hidden_layer_number (list of int, optional) – A list specifying the number of neurons in each hidden layer. Default is [100, 100].
vmin (float, optional) – The minimum velocity of the output. Default is None.
vmax (float, optional) – The maximum velocity of the output. Default is None.
unit (int, optional) – The scaling factor for the output. Default is 1000.
device (str, optional) – The device to use for computation, either ‘cpu’ or ‘cuda’. Default is ‘cpu’.
- forward()[source]
Forward pass through the MLP.
- Returns:
The output of the MLP model after processing, reshaped and scaled with the given vmin and vmax.
- Return type:
torch.Tensor
- training: bool
ADFWI.dip.model.Unet
- class ADFWI.dip.model.Unet.DoubleConv(in_channels, out_channels, mid_channels=None)[source]
Bases:
Module
A module that applies two consecutive convolutions, each followed by batch normalization and a LeakyReLU activation.
- training: bool
- class ADFWI.dip.model.Unet.Down(in_channels, out_channels)[source]
Bases:
Module
A downscaling block that applies a convolution followed by max pooling.
- training: bool
- class ADFWI.dip.model.Unet.OutConv(in_channels, out_channels)[source]
Bases:
Module
The output convolution layer that applies a 1x1 convolution to the input tensor.
- training: bool
- ADFWI.dip.model.Unet.Pkgen(n)[source]
Generates a power spectrum function with a given power-law exponent.
- class ADFWI.dip.model.Unet.UNet(model_shape, n_layers, base_channel, vmin=None, vmax=None, in_channels=1, out_channels=1, bilinear=False, grf_initialize=False, grf_alpha=0, unit=1000, device='cpu')[source]
Bases:
Module
A flexible UNet model that can be configured with different numbers of layers and channels.
- Parameters:
model_shape (tuple) – The shape of the input model (height, width).
n_layers (int) – The number of layers in the encoder-decoder network.
base_channel (int) – The base number of channels at the input.
vmin (float, optional) – The minimum value for the output, used for rescaling, default is None.
vmax (float, optional) – The maximum value for the output, used for rescaling, default is None.
in_channels (int, optional) – The number of input channels, default is 1.
out_channels (int, optional) – The number of output channels, default is 1.
bilinear (bool, optional) – Whether to use bilinear upsampling instead of transposed convolution, default is False.
grf_initialize (bool, optional) – Whether to initialize the model with a Gaussian random field, default is False.
grf_alpha (float, optional) – The power-law exponent for the Gaussian random field initialization, default is 0.
unit (int, optional) – A scaling factor for the output, default is 1000.
device (str, optional) – The device for tensor computations, default is ‘cpu’.
- forward()[source]
Forward pass of the UNet model.
- Returns:
The output tensor after processing through the UNet.
- Return type:
torch.Tensor
- training: bool
- class ADFWI.dip.model.Unet.Up(in_channels, out_channels, bilinear=True)[source]
Bases:
Module
An upscaling block that applies either bilinear upsampling or transposed convolution, followed by a convolution.
- training: bool