Tools
pad_1D(inputs, pad_value=0.0)
Pad a list of 1D tensor list to the same length.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
inputs |
List[Tensor]
|
List of 1D numpy arrays to pad. |
required |
pad_value |
float
|
Value to use for padding. Default is 0.0. |
0.0
|
Returns:
Type | Description |
---|---|
Tensor
|
torch.Tensor: Padded 2D numpy array of shape (len(inputs), max_len), where max_len is the length of the longest input array. |
Source code in training/tools.py
7 8 9 10 11 12 13 14 15 16 17 18 19 |
|
pad_2D(inputs, maxlen=None, pad_value=0.0)
Pad a list of 2D tensor arrays to the same length.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
inputs |
List[Tensor]
|
List of 2D numpy arrays to pad. |
required |
maxlen |
Union[int, None]
|
Maximum length to pad the arrays to. If None, pad to the length of the longest array. Default is None. |
None
|
pad_value |
float
|
Value to use for padding. Default is 0.0. |
0.0
|
Returns:
Type | Description |
---|---|
Tensor
|
torch.Tensor: Padded 3D numpy array of shape (len(inputs), max_len, input_dim), where max_len is the maximum length of the input arrays, and input_dim is the dimension of the input arrays. |
Source code in training/tools.py
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
|
pad_3D(inputs, B, T, L)
Pad a 3D torch tensor to a specified shape.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
inputs |
Tensor
|
3D numpy array to pad. |
required |
B |
int
|
Batch size to pad the array to. |
required |
T |
int
|
Time steps to pad the array to. |
required |
L |
int
|
Length to pad the array to. |
required |
Returns:
Type | Description |
---|---|
Tensor
|
torch.Tensor: Padded 3D numpy array of shape (B, T, L), where B is the batch size, T is the time steps, and L is the length. |
Source code in training/tools.py
41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 |
|