Skip to content

Commit 25d42b2

Browse files
author
Michal Warda
committed
Fix fixed midpoint integration update
1 parent 7b7287d commit 25d42b2

1 file changed

Lines changed: 4 additions & 1 deletion

File tree

sam_audio/model/model.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,11 @@ def _fixed_midpoint_integrate(vector_field, y0: torch.Tensor, options: Dict[str,
4444
dt = min(step_size, t1 - current_t)
4545
if dt <= 0:
4646
break
47+
start_t = y.new_tensor(current_t)
4748
midpoint_t = y.new_tensor(current_t + 0.5 * dt)
48-
y = y + dt * vector_field(midpoint_t, y)
49+
k1 = vector_field(start_t, y)
50+
midpoint_y = y + 0.5 * dt * k1
51+
y = y + dt * vector_field(midpoint_t, midpoint_y)
4952
current_t += dt
5053
return y
5154

0 commit comments

Comments
 (0)