Multi-Parameter Inversion
VTI example (vp, epsilon, delta)
The same DevitoPhysics instance can expose multiple gradient channels. This example inverts simultaneously for vp, epsilon, and delta.
Configuration
physics = DevitoPhysics(
model={
"vp": "models/vti/vp_initial.h5",
"epsilon": "models/vti/eps_initial.h5",
"delta": "models/vti/delta_initial.h5",
},
parameters=('vp', 'epsilon', 'delta'),
nbl=48,
space_order=12,
gradient={"mute": {"type": "datum", "threshold": 1.55, "cone_angle": 60.0}},
)parameters controls which Function objects are differentiated. Gradients will be returned as a dict with the same keys.
Bounds Per Parameter
bounds = {
'vp': (1.5, 5.5),
'epsilon': (0.0, 0.35),
'delta': (-0.1, 0.25),
}Pass this dict to SPG.fwi(...) to keep each parameter within a physical interval.
Gradient Inspection
import numpy as np
shot = dataset[10]
result = physics.compute_shot_gradient(shot)
grads = result['gradients']
for name, arr in grads.items():
print(name, np.linalg.norm(arr))It’s often helpful to visualise each channel before starting the optimizer:
import matplotlib.pyplot as plt
fig, axs = plt.subplots(1, 3, figsize=(12, 4), sharey=True)
for ax, name in zip(axs, ('vp', 'epsilon', 'delta')):
im = ax.imshow(grads[name].T, cmap='seismic', aspect='auto')
ax.set_title(f"{name} gradient")
fig.colorbar(im, ax=ax, shrink=0.7)
plt.show()Running SPG
optimizer = SPG(maxiter=10, ftol=1e-6, gtol=1e-8, verbose=True)
from devitohorizon.config import SamplingConfig
model_opt, f_opt, info = optimizer.fwi(
physics=physics,
dataset=dataset,
model0=physics.model,
bounds=bounds,
sampling=SamplingConfig(batch_size=6),
)The returned model_opt contains updated vp, epsilon, and delta. Each can be accessed via model_opt.vp.data, model_opt.epsilon.data, etc.