Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 12 additions & 2 deletions autoemulate/experimental/learners/stream.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from abc import abstractmethod
from dataclasses import dataclass
from dataclasses import dataclass, field

import numpy as np
import torch
Expand All @@ -19,6 +19,8 @@ class Stream(Active):
(Inherits parameters from Active)
"""

show_progress: bool = field(default=True)

@abstractmethod
def query(
self, X: TensorLike | None = None
Expand Down Expand Up @@ -51,7 +53,14 @@ def fit_samples(self, X: torch.Tensor):
Stream of input samples.
"""
X = self.check_matrix(X)
for x in (pb := tqdm(X, desc=self.__class__.__name__, leave=True)):
for x in (
pb := tqdm(
X,
desc=self.__class__.__name__,
leave=True,
disable=not self.show_progress,
)
):
self.fit(x.reshape(1, -1))
pb.set_postfix(
ordered_dict={key: val[-1] for key, val in self.metrics.items()}
Expand All @@ -76,6 +85,7 @@ def fit_batches(self, X: torch.Tensor, batch_size: int):
pb := tqdm(
range(0, X.shape[0], batch_size),
desc=f"{self.__class__.__name__} (batches)",
disable=not self.show_progress,
)
):
batch = X[i : i + batch_size]
Expand Down
Loading
Loading