Skip to content

Commit 52b2366

Browse files
committed
Minor documentation fixes (correcting internal links)
1 parent f963680 commit 52b2366

4 files changed

Lines changed: 43 additions & 45 deletions

File tree

docs/example_callback_animation.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ In this example, we will create an animation that shows three things side-by-sid
99
2. The backward-propagating wavefield (the adjoint wavefield).
1010
3. The formation of the model gradient during backpropagation.
1111

12-
We set-up the propagation as normal, using a simple single layer model. Next, we define two callback functions to store the forward and backward wavefields and the current value of the gradient with respect to the velocity model as backpropagation progresses. We can use regular Python functions for these, but, to show you how it is done, I will use a callable class for the forward callback. The `ForwardCallback` instance will be called during the forward pass, and the `backward_callback` function will be called during the backward pass. Each receives a `CallbackState <class-deepwave.common.CallbackState>` object when it is called that provides access to the simulation data. We use these to save the relevant tensors to our snapshot storage. The wavefield names are the same as those in the propagator signature, so the current wavefield is `wavefield_0`::
12+
We set-up the propagation as normal, using a simple single layer model. Next, we define two callback functions to store the forward and backward wavefields and the current value of the gradient with respect to the velocity model as backpropagation progresses. We can use regular Python functions for these, but, to show you how it is done, I will use a callable class for the forward callback. The `ForwardCallback` instance will be called during the forward pass, and the `backward_callback` function will be called during the backward pass. Each receives a :py:class:`CallbackState <deepwave.common.CallbackState>` object when it is called that provides access to the simulation data. We use these to save the relevant tensors to our snapshot storage. The wavefield names are the same as those in the propagator signature, so the current wavefield is `wavefield_0`::
1313

1414
# Storage for snapshots from callbacks
1515
callback_frequency = 1

docs/example_target_wavefield.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ The optimisation loop is then not very dissimilar to earlier examples. We'll set
5858
for i in range(50):
5959
optimiser.step(closure)
6060

61-
Lastly, we will save the wave propagation time steps so that we can make them into an animated GIF. The full example code shows two ways of achieving this. The simplest is to use Deepwave's `callback feature <example_callback_animation>`. The other uses the approach discussed in :doc:`the checkpointing example <example_checkpointing>`.
61+
Lastly, we will save the wave propagation time steps so that we can make them into an animated GIF. The full example code shows two ways of achieving this. The simplest is to use Deepwave's :doc:`callback feature <example_callback_animation>`. The other uses the approach discussed in :doc:`the checkpointing example <example_checkpointing>`.
6262

6363
Using `FFmpeg <https://ffmpeg.org>`_ to join these individual time steps into an animated GIF (although you could use other tools, such as Matplotlib)::
6464

src/deepwave/scalar.py

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1529,7 +1529,6 @@ def backward(
15291529
)
15301530

15311531
if wfc.numel() > 0 and nt > 0:
1532-
start_t = 0
15331532
forward(
15341533
v.data_ptr(),
15351534
ggv.data_ptr(),
@@ -1581,7 +1580,7 @@ def backward(
15811580
False,
15821581
v_batched,
15831582
ggv_batched,
1584-
start_t,
1583+
0,
15851584
pml_y0,
15861585
pml_y1,
15871586
pml_x0,
@@ -1743,7 +1742,6 @@ def backward(
17431742
gwfp = -gwfp
17441743

17451744
if wfc.numel() > 0 and nt > 0 and v.requires_grad:
1746-
start_t = 0
17471745
backward(
17481746
v.data_ptr(),
17491747
ggv.data_ptr(),
@@ -1804,7 +1802,7 @@ def backward(
18041802
False,
18051803
v_batched,
18061804
ggv_batched,
1807-
start_t,
1805+
nt,
18081806
pml_y0,
18091807
pml_y1,
18101808
pml_x0,
@@ -1848,6 +1846,9 @@ def backward(
18481846
None,
18491847
None,
18501848
None,
1849+
None,
1850+
None,
1851+
None,
18511852
)
18521853
return (
18531854
ggwfp[s],
@@ -1883,6 +1884,9 @@ def backward(
18831884
None,
18841885
None,
18851886
None,
1887+
None,
1888+
None,
1889+
None,
18861890
)
18871891

18881892

tests/test_scalar.py

Lines changed: 33 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -395,7 +395,7 @@ def test_unused_source_receiver(
395395
assert torch.allclose(modelf.grad, modeli.grad)
396396

397397

398-
def run_scalarfunc(nt: int = 3, gradgrad: bool = False) -> None:
398+
def run_scalarfunc(nt: int = 3) -> None:
399399
"""Runs scalar_func for testing purposes."""
400400
from deepwave.scalar import scalar_func
401401

@@ -500,39 +500,38 @@ def run_scalarfunc(nt: int = 3, gradgrad: bool = False) -> None:
500500
1,
501501
),
502502
)
503-
if gradgrad:
504-
torch.autograd.gradgradcheck(
505-
scalar_func,
506-
(
507-
c,
508-
source_amplitudes,
509-
wfc,
510-
wfp,
511-
psiy,
512-
psix,
513-
zetay,
514-
zetax,
515-
ay,
516-
ax,
517-
by,
518-
bx,
519-
dbydy,
520-
dbxdx,
521-
sources_i,
522-
receivers_i,
523-
dy,
524-
dx,
525-
dt,
526-
nt,
527-
step_ratio,
528-
accuracy,
529-
pml_width,
530-
n_batch,
531-
None,
532-
None,
533-
1,
534-
),
535-
)
503+
torch.autograd.gradgradcheck(
504+
scalar_func,
505+
(
506+
c,
507+
source_amplitudes,
508+
wfc,
509+
wfp,
510+
psiy,
511+
psix,
512+
zetay,
513+
zetax,
514+
ay,
515+
ax,
516+
by,
517+
bx,
518+
dbydy,
519+
dbxdx,
520+
sources_i,
521+
receivers_i,
522+
dy,
523+
dx,
524+
dt,
525+
nt,
526+
step_ratio,
527+
accuracy,
528+
pml_width,
529+
n_batch,
530+
None,
531+
None,
532+
1,
533+
),
534+
)
536535

537536

538537
def test_scalarfunc() -> None:
@@ -541,11 +540,6 @@ def test_scalarfunc() -> None:
541540
run_scalarfunc(nt=5)
542541

543542

544-
def test_scalarfunc_gradgrad() -> None:
545-
"""Test scalar_func with gradgrad enabled."""
546-
run_scalarfunc(nt=4, gradgrad=True)
547-
548-
549543
def test_gradcheck_2d() -> None:
550544
"""Test gradcheck in a 2D model."""
551545
run_gradcheck_2d(propagator=scalarprop)

0 commit comments

Comments
 (0)