Skip to content

Commit

Permalink
modified fit function to track training losses
Browse files Browse the repository at this point in the history
  • Loading branch information
sameerashahh committed Jul 3, 2024
1 parent 51301a4 commit f8c4ae5
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/dynadojo/baselines/aug_ode.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,8 @@ def fit(self, x: np.ndarray, epochs=100, **kwargs):
x = torch.tensor(x, dtype=torch.float32)
state = x[:, 0, :]
step = end = epochs / self._timesteps

losses = []

for _ in range(epochs):
if _ % step == 0:
t = torch.linspace(0.0, end, self._timesteps)
Expand All @@ -40,6 +41,10 @@ def fit(self, x: np.ndarray, epochs=100, **kwargs):
loss = self.mse_loss(pred, x).float()
loss.backward()
self.opt.step()
losses.append(loss)
return {
"train_losses": losses
}

def predict(self, x0, timesteps):
x0 = torch.tensor(x0, dtype=torch.float32)
Expand Down

0 comments on commit f8c4ae5

Please sign in to comment.