sgdrf.subsample

Classes for subsampling strategies.

Module Contents

class sgdrf.subsample.ExponentialSubsampler(n: int, device: torch.device, exp: float)

A subsampling strategy that has an exponential decay, with larger probabilities being more recent.

Parameters:
  • n (int) – Number of subsamples to draw

  • device (torch.device) – Pytorch device to use

  • exp (float) – Exponential parameter

n

Number of subsamples to draw

Type:

int

device

Pytorch device to use

Type:

torch.device

exp

Exponential parameter

Type:

float

dist(t: int) torch.Tensor

Get distribution for this subsampler, for t observations.

Parameters:

t (int) – The number of observations to get a distribution for

Returns:

Tensor of topic probabilities of length t

Return type:

torch.Tensor

class sgdrf.subsample.LatestSubsampler(n: int, device: torch.device)

A subsampling strategy that samples the n most recent observations with probability 1.

Parameters:
  • n (int) – Number of subsamples to draw

  • device (torch.device) – Pytorch device to use

n

Number of subsamples to draw

Type:

int

device

Pytorch device to use

Type:

torch.device

dist(t: int) torch.Tensor

Get distribution for this subsampler, for t observations.

Parameters:

t (int) – The number of observations to get a distribution for

Returns:

Tensor of topic probabilities of length t

Return type:

torch.Tensor

class sgdrf.subsample.MixingSubsampler(n: int, device: torch.device, weight: float, s1: Subsampler, s2: Subsampler)

A subsampling strategy that mixes two other subsampling strategies with a given weight.

Parameters:
  • n (int) – Number of subsamples to draw

  • device (torch.device) – Pytorch device to use

  • weight (float) – Weight associated with subsampler s1 (s2 is associated with 1 - weight)

  • s1 (Subsampler) – The first subsampler to mix

  • s2 (Subsampler) – The second subsampler to mix

n

Number of subsamples to draw

Type:

int

device

Pytorch device to use

Type:

torch.device

weight

Weight associated with subsampler s1 (s2 is associated with 1 - weight)

Type:

float

s1

The first subsampler to mix

Type:

Subsampler

s2

The second subsampler to mix

Type:

Subsampler

dist(t: int)

Get distribution for this subsampler, for t observations.

Parameters:

t (int) – The number of observations to get a distribution for

Returns:

Tensor of topic probabilities of length t

Return type:

torch.Tensor

class sgdrf.subsample.Subsampler(n: int, device: torch.device)

An abstract class for SGDRF subsampling strategies.

Parameters:
  • n (int) – Number of subsamples to draw

  • device (torch.device) – Pytorch device to use

n

Number of subsamples to draw

Type:

int

device

Pytorch device to use

Type:

torch.device

abstract dist(t: int) torch.Tensor

Get distribution for this subsampler, for t observations.

Parameters:

t (int) – The number of observations to get a distribution for

Returns:

Tensor of topic probabilities of length t

Return type:

torch.Tensor

subsample(t: int) torch.Tensor

Generate a subsample, for t observations.

Parameters:

t (int) – The number of observations to get a subsample for

Returns:

Tensor of subsample

Return type:

torch.Tensor

class sgdrf.subsample.UniformSubsampler(n: int, device: torch.device)

A subsampling strategy that has uniform values for all observations.

Parameters:
  • n (int) – Number of subsamples to draw

  • device (torch.device) – Pytorch device to use

n

Number of subsamples to draw

Type:

int

device

Pytorch device to use

Type:

torch.device

dist(t: int) torch.Tensor

Get distribution for this subsampler, for t observations.

Parameters:

t (int) – The number of observations to get a distribution for

Returns:

Tensor of topic probabilities of length t

Return type:

torch.Tensor