PyTorch backend¶
Install the optional torch extra to run this API. Read the
PyTorch guide for an example with backpropagation.
compute accepts a TensorLandscapeSample, feature selectors, y_normalization, and options.
It returns the same result model as the NumPy backend, with scalar tensors as feature values.
This backend has no rng or workers parameter.
list_features() returns specifications for the Torch profile only. list_capabilities()
reports device, dtype, and autograd support including the requested preprocessing mode.
Known features without a Torch implementation raise UnsupportedFeatureError; unavailable
devices raise UnsupportedFeatureDeviceError.
compute ¶
compute(
sample: TensorLandscapeSample,
features: str | tuple[str, ...] | list[str],
*,
y_normalization: YNormalization = "minmax",
options: FeatureOptions | None = None,
) -> ComputationResult[torch.Tensor]
Compute tensor features with min-max objective normalization by default.
y_normalization=None preserves raw canonical objectives.
Min-max preprocessing is piecewise differentiable.
All modes preserve the sample's tensors, dtype, device, and autograd history.
options is a nested mapping keyed by feature group, for example
{"fitness_distance": {"proportion_of_best": 0.25}}. Omit it to use defaults.
Unknown groups and option names are rejected. Fitness-distance features always use
Euclidean distances to the best selected observation. Effective options are recorded
in result.metadata.options as an immutable snapshot.
Source code in src/orivex/torch/api.py
TensorLandscapeSample
dataclass
¶
A validated single-landscape tensor sample with mutation detection.
Source code in src/orivex/torch/sample.py
44 45 46 47 48 49 50 51 52 53 54 55 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 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 | |
__init__ ¶
__init__(
x: Tensor,
y: Tensor,
lower: TensorValue,
upper: TensorValue,
sense: ObjectiveSense
| ObjectiveSenseName = ObjectiveSense.MINIMIZE,
) -> None
Source code in src/orivex/torch/sample.py
validate_unchanged ¶
Source code in src/orivex/torch/sample.py
list_features ¶
Return the mathematical specifications implemented by this backend.
list_capabilities ¶
Return capabilities including a conservative preprocessing autograd guarantee.