Skip to content

Commit

Permalink
change default subsampled_target_frac
Browse files Browse the repository at this point in the history
  • Loading branch information
jonhue committed Mar 4, 2024
1 parent 9b3f108 commit bb9da17
Show file tree
Hide file tree
Showing 8 changed files with 13 additions and 13 deletions.
4 changes: 2 additions & 2 deletions afsl/acquisition_functions/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -346,12 +346,12 @@ class Targeted(ABC):
def __init__(
self,
target: torch.Tensor,
subsampled_target_frac: float = 0.5,
subsampled_target_frac: float = 1,
max_target_size: int | None = None,
):
r"""
:param target: Tensor of prediction targets (shape $m \times d$).
:param subsampled_target_frac: Fraction of the target to be subsampled in each iteration. Must be in $(0,1]$. Default is $0.5$.
:param subsampled_target_frac: Fraction of the target to be subsampled in each iteration. Must be in $(0,1]$. Default is $1$.
:param max_target_size: Maximum size of the target to be subsampled in each iteration. Default is `None` in which case the target may be arbitrarily large.
"""

Expand Down
4 changes: 2 additions & 2 deletions afsl/acquisition_functions/bace.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ def __init__(
self,
target: torch.Tensor,
noise_std=1.0,
subsampled_target_frac: float = 0.5,
subsampled_target_frac: float = 1,
max_target_size: int | None = None,
mini_batch_size=DEFAULT_MINI_BATCH_SIZE,
embedding_batch_size=DEFAULT_EMBEDDING_BATCH_SIZE,
Expand All @@ -129,7 +129,7 @@ def __init__(
r"""
:param target: Tensor of prediction targets (shape $m \times d$).
:param noise_std: Standard deviation of the noise.
:param subsampled_target_frac: Fraction of the target to be subsampled in each iteration. Must be in $(0,1]$. Default is $0.5$. Ignored if `target` is `None`.
:param subsampled_target_frac: Fraction of the target to be subsampled in each iteration. Must be in $(0,1]$. Default is $1$. Ignored if `target` is `None`.
:param max_target_size: Maximum size of the target to be subsampled in each iteration. Default is `None` in which case the target may be arbitrarily large. Ignored if `target` is `None`.
:param mini_batch_size: Size of mini-batch used for computing the acquisition function.
:param embedding_batch_size: Batch size used for computing the embeddings.
Expand Down
4 changes: 2 additions & 2 deletions afsl/acquisition_functions/cosine_similarity.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ class CosineSimilarity(Targeted, BatchAcquisitionFunction):
def __init__(
self,
target: torch.Tensor,
subsampled_target_frac: float = 0.5,
subsampled_target_frac: float = 1,
max_target_size: int | None = None,
mini_batch_size=DEFAULT_MINI_BATCH_SIZE,
embedding_batch_size=DEFAULT_EMBEDDING_BATCH_SIZE,
Expand All @@ -47,7 +47,7 @@ def __init__(
):
r"""
:param target: Tensor of prediction targets (shape $m \times d$).
:param subsampled_target_frac: Fraction of the target to be subsampled in each iteration. Must be in $(0,1]$. Default is $0.5$. Ignored if `target` is `None`.
:param subsampled_target_frac: Fraction of the target to be subsampled in each iteration. Must be in $(0,1]$. Default is $1$. Ignored if `target` is `None`.
:param max_target_size: Maximum size of the target to be subsampled in each iteration. Default is `None` in which case the target may be arbitrarily large. Ignored if `target` is `None`.
:param mini_batch_size: Size of mini-batch used for computing the acquisition function.
:param embedding_batch_size: Batch size used for computing the embeddings.
Expand Down
2 changes: 1 addition & 1 deletion afsl/acquisition_functions/information_density.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ def __init__(
self,
target: torch.Tensor,
beta=1.0,
subsampled_target_frac: float = 0.5,
subsampled_target_frac: float = 1,
max_target_size: int | None = None,
mini_batch_size=DEFAULT_MINI_BATCH_SIZE,
embedding_batch_size=DEFAULT_EMBEDDING_BATCH_SIZE,
Expand Down
2 changes: 1 addition & 1 deletion afsl/acquisition_functions/max_dist.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ class MaxDist(SequentialAcquisitionFunction[ModelWithEmbeddingOrKernel, Distance
This acquisition function rests on the assumption that the model induces a distance $d(\vx,\vxp)$ between points $\vx$ and $\vxp$, either via an embedding or a kernel.
- **Embeddings** $\vphi(\cdot)$ induce the (euclidean) *embedding distance* \\[ d_\vphi(\vx,\vxp) \defeq \norm{\vphi(\vx) - \vphi(\vxp)}_2. \\]
- **Embeddings** $\vphi(\cdot)$ induce the (Euclidean) *embedding distance* \\[ d_\vphi(\vx,\vxp) \defeq \norm{\vphi(\vx) - \vphi(\vxp)}_2. \\]
- A **kernel** $k$ induces the *kernel distance* \\[ d_k(\vx,\vxp) \defeq = \sqrt{k(\vx,\vx) + k(\vxp,\vxp) - 2 k(\vx,\vxp)}. \\]
It is straightforward to see that if $k(\vx,\vxp) = \vphi(\vx)^\top \vphi(\vxp)$ then embedding and kernel distances coincide, i.e., $d_\vphi(\vx,\vxp) = d_k(\vx,\vxp)$.
Expand Down
6 changes: 3 additions & 3 deletions afsl/active_data_loader.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ class ActiveDataLoader(Generic[M]):
r"""Acquisition function to be used for data selection."""

subsampled_target_frac: float
r"""Fraction of the target to be subsampled in each iteration. Must be in $(0,1]$. Default is $0.5$."""
r"""Fraction of the target to be subsampled in each iteration. Must be in $(0,1]$. Default is $1$."""

max_target_size: int | None
r"""
Expand Down Expand Up @@ -71,7 +71,7 @@ def initialize(
dataset: Dataset,
target: torch.Tensor | None,
batch_size: int,
subsampled_target_frac: float = 0.5,
subsampled_target_frac: float = 1,
max_target_size: int | None = None,
mini_batch_size: int = DEFAULT_MINI_BATCH_SIZE,
embedding_batch_size: int = DEFAULT_EMBEDDING_BATCH_SIZE,
Expand All @@ -84,7 +84,7 @@ def initialize(
:param dataset: Inputs (shape $n \times d$) to be selected from.
:param target: Tensor of prediction targets (shape $m \times d$) or `None`.
:param batch_size: Size of the batch to be selected.
:param subsampled_target_frac: Fraction of the target to be subsampled in each iteration. Must be in $(0,1]$. Default is $0.5$. Ignored if `target` is `None`.
:param subsampled_target_frac: Fraction of the target to be subsampled in each iteration. Must be in $(0,1]$. Default is $1$. Ignored if `target` is `None`.
:param max_target_size: Maximum size of the target to be subsampled in each iteration. Default is `None` in which case the target may be arbitrarily large. Ignored if `target` is `None`.
:param mini_batch_size: Size of mini batches used for computing the acquisition function.
:param embedding_batch_size: Batch size used for computing the embeddings.
Expand Down
2 changes: 1 addition & 1 deletion examples/fine_tuning/cifar_100/experiment.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@

MINI_BATCH_SIZE = 1_000
NUM_WORKERS = 4
NUM_ROUNDS = 100
NUM_ROUNDS = 101

DEFAULT_NOISE_STD = 1.0
DEFAULT_QUERY_BATCH_SIZE = 10
Expand Down
2 changes: 1 addition & 1 deletion examples/fine_tuning/mnist/experiment.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@

MINI_BATCH_SIZE = 1_000
NUM_WORKERS = 4
NUM_ROUNDS = 100
NUM_ROUNDS = 101

DEFAULT_NOISE_STD = 0.01
DEFAULT_QUERY_BATCH_SIZE = 1
Expand Down

0 comments on commit bb9da17

Please sign in to comment.