pycsamt.ai.inversion.inv2d#
EMInverter2D — high-level U-Net–based 2-D MT inversion pipeline.
Wraps UNet2DNet with a complete
data-loading → normalisation → training → prediction workflow.
Input / output convention#
Input
X:ndarray (n_profiles, n_components, n_freqs, n_stations)— each entry is one profile of MT apparent-resistivity / phase maps.Target
y:ndarray (n_profiles, n_depth, n_stations)— 2-D log₁₀(ρ) sections.
Both n_freqs and n_depth may differ (the U-Net uses bilinear
upsampling); n_stations must match between X and y.
Synthetic training data#
When PyTorch is available and a 2-D pre-built dataset is not on hand,
use generate_dataset() to build
pseudo-2-D profiles by running the 1-D MT forward solver independently
at each virtual station, then stack the per-station feature vectors into
the 2-D panel format expected here.
Example
>>> from pycsamt.ai.inversion import EMInverter2D
>>> inv = EMInverter2D(n_components=4, n_depth=40, n_stations=20, n_freqs=32)
>>> inv.fit(X_train, y_train, epochs=30)
EMInverter2D(arch='unet', fitted)
>>> rho_pred = inv.predict(X_test)
Classes
|
U-Net–based 2-D MT inversion estimator. |
- class pycsamt.ai.inversion.inv2d.EMInverter2D(n_components=4, n_depth=40, n_stations=20, n_freqs=32, *, arch='unet', unet_depth=None, channels=None, dropout=0.2, device=None, log_rho_out=True, **net_kwargs)[source]#
Bases:
BaseEMNetU-Net–based 2-D MT inversion estimator.
- Parameters:
n_components (int, default 4) – Number of input channels (EM data components per frequency and station).
n_depth (int, default 40) – Number of depth cells in the target resistivity section.
n_stations (int, default 20) – Number of stations along the profile.
n_freqs (int, default 32) – Number of frequency channels in the input data.
arch (str, default
'unet') – Network architecture. Only'unet'is supported in Phase 4.device (str or None) – Compute device.
log_rho_out (bool, default True) – If
True, targets and predictions are in log₁₀(ρ) scale.**net_kwargs – Additional keyword arguments forwarded to the architecture factory (e.g.
channels,dropout).unet_depth (int | None)
dropout (float)
- fit(X, y=None, *, epochs=100, batch_size=16, lr=0.001, patience=15, val_frac=0.1, grad_clip=1.0, seed=None, verbose=True)[source]#
Train the 2-D inversion network.
- Parameters:
X (ndarray (n_profiles, n_components, n_freqs, n_stations)) – Input data panels.
y (ndarray (n_profiles, n_depth, n_stations)) – Target 2-D log₁₀(ρ) sections.
epochs (int) – Standard training hyper-parameters.
batch_size (int) – Standard training hyper-parameters.
lr (float) – Standard training hyper-parameters.
patience (int) – Standard training hyper-parameters.
val_frac (float) – Standard training hyper-parameters.
grad_clip (float | None) – Standard training hyper-parameters.
seed (int | None) – Standard training hyper-parameters.
verbose (bool) – Standard training hyper-parameters.
- Return type:
self
- predict(X, *, as_log_rho=True)[source]#
Predict 2-D resistivity sections.
- Parameters:
X (ndarray (n_profiles, n_components, n_freqs, n_stations))
as_log_rho (bool) – If
True(default) output is log₁₀(ρ); otherwise linear ρ.
- Returns:
rho_2d
- Return type:
ndarray (n_profiles, n_depth, n_stations)