tensor_conversion
deque2rolling_tensor(window, device='cpu', dtype=torch.float32)
¶
Convert a dictionary to a rolling tensor.
PARAMETER | DESCRIPTION |
---|---|
window |
Rolling window.
TYPE:
|
device |
Device.
DEFAULT:
|
dtype |
Dtype.
DEFAULT:
|
RETURNS | DESCRIPTION |
---|---|
torch.Tensor
|
|
df2tensor(X, features, default_value=0, device='cpu', dtype=torch.float32)
¶
Convert a dataframe to a tensor.
PARAMETER | DESCRIPTION |
---|---|
X |
Dataframe.
TYPE:
|
features |
Set of possible features.
TYPE:
|
default_value |
Value to use for features not present in x.
TYPE:
|
device |
Device.
DEFAULT:
|
dtype |
Dtype.
DEFAULT:
|
RETURNS | DESCRIPTION |
---|---|
torch.Tensor
|
|
dict2tensor(x, features, default_value=0, device='cpu', dtype=torch.float32)
¶
Convert a dictionary to a tensor.
PARAMETER | DESCRIPTION |
---|---|
x |
Dictionary.
TYPE:
|
features |
Set of possible features.
TYPE:
|
default_value |
Value to use for features not present in x.
TYPE:
|
device |
Device.
TYPE:
|
dtype |
Dtype.
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
torch.Tensor
|
|
float2tensor(y, device='cpu', dtype=torch.float32)
¶
Convert a float to a tensor.
PARAMETER | DESCRIPTION |
---|---|
y |
Float.
TYPE:
|
device |
Device.
DEFAULT:
|
dtype |
Dtype.
DEFAULT:
|
RETURNS | DESCRIPTION |
---|---|
torch.Tensor
|
|
labels2onehot(y, classes, n_classes=None, device='cpu', dtype=torch.float32)
¶
Convert a label or a list of labels to a one-hot encoded tensor.
PARAMETER | DESCRIPTION |
---|---|
y |
Label or list of labels.
TYPE:
|
classes |
Classes.
TYPE:
|
n_classes |
Number of classes.
TYPE:
|
device |
Device.
DEFAULT:
|
dtype |
Dtype.
DEFAULT:
|
RETURNS | DESCRIPTION |
---|---|
torch.Tensor
|
|