zamba.pytorch.utils¶
build_multilayer_perceptron(input_size, hidden_layer_sizes, output_size, activation=torch.nn.ReLU, dropout=None, output_dropout=None, output_activation=None)
¶
Builds a multilayer perceptron.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
input_size
|
int
|
Size of first input layer. |
required |
hidden_layer_sizes
|
tuple of int
|
If provided, size of hidden layers. |
required |
output_size
|
int
|
Size of the last output layer. |
required |
activation
|
Module
|
Activation layer between each pair of layers. |
ReLU
|
dropout
|
float
|
If provided, insert dropout layers with the following dropout rate in between each pair of layers. |
None
|
output_dropout
|
float
|
If provided, insert a dropout layer with the following dropout rate before the output. |
None
|
output_activation
|
Module
|
Activation layer after the final layer. |
None
|
Returns: torch.nn.Sequential
Source code in zamba/pytorch/utils.py
56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 | |
configure_inference_determinism(*, seed=None, deterministic=False)
¶
Seed RNGs for inference and optionally enable strict GPU determinism.
Seeding always runs so frame sampling and other stochastic preprocessing are
reproducible. When deterministic is True, also request deterministic CUDA/cuDNN
algorithms (best effort; may reduce GPU throughput).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
seed
|
Optional[int]
|
Random seed for Python, NumPy, and PyTorch. Defaults to |
None
|
deterministic
|
bool
|
If True, enable strict deterministic CUDA/cuDNN algorithms where supported (best effort; some GPU ops may remain non-deterministic and will warn rather than error). Disables cuDNN benchmark mode. May reduce GPU throughput. |
False
|
Source code in zamba/pytorch/utils.py
27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 | |
filter_scheduler_params(scheduler_cls, params)
¶
Return scheduler kwargs supported by the scheduler constructor.
Configs and checkpoints may include deprecated args (e.g. verbose was removed
from PyTorch lr schedulers in 2.7).
Source code in zamba/pytorch/utils.py
11 12 13 14 15 16 17 18 19 20 21 22 23 24 | |