utils#

Helper functions for PyTorch forecasting

Functions

apply_to_list(obj, func)

Apply function to a list of objects or directly if passed value is not a list.

autocorrelation(input[, dim])

Computes the autocorrelation of samples at dimension dim.

concat_sequences(sequences)

Concatenate RNN sequences.

create_mask(size, lengths[, inverse])

Create boolean masks of shape len(lenghts) x size.

detach(x)

Detach object

get_embedding_size(n[, max_size])

Determine empirically good embedding sizes (formula taken from fastai).

groupby_apply(keys, values[, bins, ...])

Groupby apply for torch tensors

integer_histogram(data[, min, max])

Create histogram of integers in predefined range

masked_op(tensor[, op, dim, mask])

Calculate operation on masked tensor.

move_to_device(x, device)

Move object to device.

next_fast_len(size)

Returns the next largest number n >= size whose prime factors are all 2, 3, or 5.

padded_stack(tensors[, side, mode, value])

Stack tensors along first dimension and pad them along last dimension to ensure their size is equal.

profile(function, profile_fname[, filter, ...])

Profile a given function with vmprof.

repr_class(obj, attributes[, ...])

Print class name and parameters.

to_list(value)

Convert value or list to list of values.

unpack_sequence(sequence)

Unpack RNN sequence.

unsqueeze_like(tensor, like)

Unsqueeze last dimensions of tensor to match another tensor's number of dimensions.

Classes

InitialParameterRepresenterMixIn()

OutputMixIn()

MixIn to give namedtuple some access capabilities of a dictionary

TupleOutputMixIn()

MixIn to give output a namedtuple-like access capabilities with to_network_output() function.