trajdl.tokenizers.slot package#

class trajdl.tokenizers.slot.Bucketizer(lower_bound: float, upper_bound: float, num_buckets: int)[source]#

Bases: object

A class to create buckets for numerical data, allowing for indexing of values into buckets.

Parameters:
  • lower_bound (float) – The lower bound of the range.

  • upper_bound (float) – The upper bound of the range.

  • num_buckets (int) – The number of buckets to create within the specified range.

bucket_size#

The size of each bucket.

Type:

float

get_bucket_index(value):

Returns the index of the bucket that the given value falls into.

get_bucket_index(value: float)[source]#

Get the index of the bucket that the given value belongs to.

Parameters:

value (float) – The value to be placed in a bucket.

Returns:

The index of the bucket that contains the value.

Return type:

int

get_bucket_indices(tensor: Tensor) LongTensor[source]#

Get the indices of the buckets for each value in the input tensor.

static load(path: str | Path) Bucketizer[source]#
property lower_bound: float#
property num_buckets: int#
save(path: str | Path)[source]#
property upper_bound: float#