File tree Expand file tree Collapse file tree
aepsych/models/inducing_points Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1313from aepsych .utils import get_dims
1414from botorch .models .utils .inducing_point_allocators import InducingPointAllocator
1515
16+ EMPTY_SIZE = torch .Size ([])
17+
1618
1719class BaseAllocator (InducingPointAllocator , ConfigurableMixin ):
1820 """Base class for inducing point allocators."""
@@ -34,7 +36,7 @@ def allocate_inducing_points(
3436 inputs : torch .Tensor | None = None ,
3537 covar_module : torch .nn .Module | None = None ,
3638 num_inducing : int = 100 ,
37- input_batch_shape : torch .Size = torch . Size ([]) ,
39+ input_batch_shape : torch .Size = EMPTY_SIZE ,
3840 ) -> torch .Tensor :
3941 """
4042 Abstract method for allocating inducing points. Must replace the
Original file line number Diff line number Diff line change 88from typing import Any
99
1010import torch
11- from aepsych .models .inducing_points .base import BaseAllocator
11+ from aepsych .models .inducing_points .base import BaseAllocator , EMPTY_SIZE
1212
1313
1414class FixedAllocator (BaseAllocator ):
@@ -31,7 +31,7 @@ def allocate_inducing_points(
3131 inputs : torch .Tensor | None = None ,
3232 covar_module : torch .nn .Module | None = None ,
3333 num_inducing : int = 100 ,
34- input_batch_shape : torch .Size = torch . Size ([]) ,
34+ input_batch_shape : torch .Size = EMPTY_SIZE ,
3535 ) -> torch .Tensor :
3636 """Allocate inducing points by returning the fixed inducing points.
3737
@@ -93,7 +93,7 @@ def allocate_inducing_points(
9393 inputs : torch .Tensor | None = None ,
9494 covar_module : torch .nn .Module | None = None ,
9595 num_inducing : int = 100 ,
96- input_batch_shape : torch .Size = torch . Size ([]) ,
96+ input_batch_shape : torch .Size = EMPTY_SIZE ,
9797 ) -> torch .Tensor :
9898 points = self .main_allocator .allocate_inducing_points (
9999 inputs = inputs ,
Original file line number Diff line number Diff line change 66# LICENSE file in the root directory of this source tree.
77
88import torch
9- from aepsych .models .inducing_points .base import BaseAllocator
9+ from aepsych .models .inducing_points .base import BaseAllocator , EMPTY_SIZE
1010from botorch .models .utils .inducing_point_allocators import (
1111 GreedyVarianceReduction as BaseGreedyVarianceReduction ,
1212)
@@ -18,7 +18,7 @@ def allocate_inducing_points(
1818 inputs : torch .Tensor | None = None ,
1919 covar_module : torch .nn .Module | None = None ,
2020 num_inducing : int = 100 ,
21- input_batch_shape : torch .Size = torch . Size ([]) ,
21+ input_batch_shape : torch .Size = EMPTY_SIZE ,
2222 ) -> torch .Tensor :
2323 """Allocate inducing points using the GreedyVarianceReduction strategy. This is
2424 a thin wrapper around BoTorch's GreedyVarianceRedution inducing point allocator.
Original file line number Diff line number Diff line change 66# LICENSE file in the root directory of this source tree.
77
88import torch
9- from aepsych .models .inducing_points .base import BaseAllocator
9+ from aepsych .models .inducing_points .base import BaseAllocator , EMPTY_SIZE
1010from scipy .cluster .vq import kmeans2
1111
1212
@@ -18,7 +18,7 @@ def allocate_inducing_points(
1818 inputs : torch .Tensor | None = None ,
1919 covar_module : torch .nn .Module | None = None ,
2020 num_inducing : int = 100 ,
21- input_batch_shape : torch .Size = torch . Size ([]) ,
21+ input_batch_shape : torch .Size = EMPTY_SIZE ,
2222 ) -> torch .Tensor :
2323 """
2424 Generates `num_inducing` inducing points using k-means++ initialization on the input data.
Original file line number Diff line number Diff line change 99
1010import torch
1111from aepsych .config import Config
12- from aepsych .models .inducing_points .base import BaseAllocator
12+ from aepsych .models .inducing_points .base import BaseAllocator , EMPTY_SIZE
1313from botorch .utils .sampling import draw_sobol_samples
1414
1515
@@ -36,7 +36,7 @@ def allocate_inducing_points(
3636 inputs : torch .Tensor | None = None ,
3737 covar_module : torch .nn .Module | None = None ,
3838 num_inducing : int = 100 ,
39- input_batch_shape : torch .Size = torch . Size ([]) ,
39+ input_batch_shape : torch .Size = EMPTY_SIZE ,
4040 ) -> torch .Tensor :
4141 """
4242 Generates `num_inducing` inducing points within the specified bounds using Sobol sampling.
You can’t perform that action at this time.
0 commit comments