Accumulator¶
- class Accumulator[source]¶
Bases:
ModuleUsed to accumulate updates for a parameter.
- forward(param: Tensor, **kwargs) Tensor[source]¶
Computes the update and returns a tensor with it applied.
- Parameters:
param (torch.Tensor) – parameter being updated.
- Returns:
parameter with the update applied.
- Return type:
- fullbound(bound: FullBounding | None, max: float | None = None, min: float | None = None, /, **kwargs: Any) None[source]¶
Sets the function used for parameter bounding on the upper and lower limits.
When
boundisNone, no full bound will be applied (and will remove any upper or lower bound present). Whenboundis notNone, thenmaxormincannot beNone.- Parameters:
bound (FullBounding | None) – bounding function.
max (float | None, optional) – upper bound. Defaults to
None.min (float | None, optional) – lower bound. Defaults to
None.**kwargs (Any) – keyword arguments for the bounding function.
- lowerbound(bound: HalfBounding | None, min: float | None = None, /, **kwargs: Any) None[source]¶
Sets the function used for parameter bounding on the lower limit.
When
boundisNone, no lower bound will be applied (and will remove any full bound present). Whenboundis notNone, themmincannot beNone.- Parameters:
bound (HalfBounding | None) – bounding function.
min (float | None, optional) – lower bound. Defaults to
None.**kwargs (Any) – keyword arguments for the bounding function.
- property neg: Tensor | None¶
Negative update component.
- Parameters:
value (torch.Tensor | None) – appends to update component.
- Returns:
accumulated update component.
- Return type:
torch.Tensor | None
- property pos: Tensor | None¶
Positive update component.
- Parameters:
value (torch.Tensor | None) – appends to update component.
- Returns:
accumulated update component.
- Return type:
torch.Tensor | None
- reduction(fn: Callable[[Tensor, int], Tensor] | None = None) None[source]¶
Sets the function used for reducing multiple updates.
When
fnisNone, it sets the default reducer,torch.sum().- Parameters:
fn (Callable[[torch.Tensor, int], torch.Tensor] | None, optional) – function for reducing updates. Defaults to
None.
- update(param: Tensor, **kwargs) Tensor | None[source]¶
Computes the update.
- Parameters:
param (torch.Tensor) – parameter being updated.
- Returns:
value of the update.
- Return type:
torch.Tensor | None
- upperbound(bound: HalfBounding | None, max: float | None = None, /, **kwargs: Any) None[source]¶
Sets the function used for parameter bounding on the upper limit.
When
boundisNone, no upper bound will be applied (and will remove any full bound present). Whenboundis notNone, themmaxcannot beNone.- Parameters:
bound (HalfBounding | None) – bounding function.
max (float | None, optional) – upper bound. Defaults to
None.**kwargs (Any) – keyword arguments for the bounding function.