Bases: BaseScheduler
Scheduler that maintains a constant parameter value.
This scheduler returns the same value at every step, effectively providing no scheduling. It's useful as a baseline or when you want to disable scheduling for certain parameters while keeping the scheduler interface.
Mathematical Formula
\[v(t) = v_0 \text{ for all } t \geq 0\]
where \(v_0\) is the start_value.
Parameters:
| Name | Type | Description | Default |
start_value | float | The constant value to maintain. | required |
Basic Usage
| scheduler = ConstantScheduler(start_value=0.01)
for i in range(5):
value = scheduler.step()
print(f"Step {i+1}: {value}") # Always prints 0.01
|
Using with Samplers
| from torchebm.samplers import LangevinDynamics
constant_step = ConstantScheduler(start_value=0.05)
sampler = LangevinDynamics(
energy_function=energy_fn,
step_size=constant_step,
noise_scale=0.1
)
|
Source code in torchebm/core/base_scheduler.py
| class ConstantScheduler(BaseScheduler):
r"""
Scheduler that maintains a constant parameter value.
This scheduler returns the same value at every step, effectively providing
no scheduling. It's useful as a baseline or when you want to disable
scheduling for certain parameters while keeping the scheduler interface.
!!! info "Mathematical Formula"
$$v(t) = v_0 \text{ for all } t \geq 0$$
where \(v_0\) is the start_value.
Args:
start_value (float): The constant value to maintain.
!!! example "Basic Usage"
```python
scheduler = ConstantScheduler(start_value=0.01)
for i in range(5):
value = scheduler.step()
print(f"Step {i+1}: {value}") # Always prints 0.01
```
!!! tip "Using with Samplers"
```python
from torchebm.samplers import LangevinDynamics
constant_step = ConstantScheduler(start_value=0.05)
sampler = LangevinDynamics(
energy_function=energy_fn,
step_size=constant_step,
noise_scale=0.1
)
```
"""
def _compute_value(self) -> float:
r"""
Return the constant value.
Returns:
float: The constant start_value.
"""
return self.start_value
|
_compute_value
_compute_value() -> float
Return the constant value.
Returns:
| Name | Type | Description |
float | float | The constant start_value. |
Source code in torchebm/core/base_scheduler.py
| def _compute_value(self) -> float:
r"""
Return the constant value.
Returns:
float: The constant start_value.
"""
return self.start_value
|