Advantage Estimation
lerax.advantage.AbstractAdvantageEstimator
Bases: eqx.Module
Estimates advantages and returns from a trajectory segment.
Attributes:
| Name | Type | Description |
|---|---|---|
gamma |
eqx.AbstractVar[Float[ArrayLike, '']]
|
Discount factor. |
__call__
abstractmethod
__call__(
rewards: Float[Array, " T"],
values: Float[Array, " T"],
dones: Bool[Array, " T"],
last_value: Float[ArrayLike, ""],
) -> tuple[Float[Array, " T"], Float[Array, " T"]]
Compute advantages and returns.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
rewards
|
Float[Array, ' T']
|
Per-step rewards. |
required |
values
|
Float[Array, ' T']
|
Per-step value estimates. |
required |
dones
|
Bool[Array, ' T']
|
Whether each step ended an episode. |
required |
last_value
|
Float[ArrayLike, '']
|
Bootstrap value after the trajectory segment. Strict episodic estimators may ignore it. |
required |
Returns:
| Type | Description |
|---|---|
tuple[Float[Array, ' T'], Float[Array, ' T']]
|
The advantages and returns, each with shape |
lerax.advantage.discounted_returns
discounted_returns(
rewards: Float[Array, " T"],
dones: Bool[Array, " T"],
final_value: Float[ArrayLike, ""],
gamma: Float[ArrayLike, ""],
) -> Float[Array, " T"]
Compute discounted returns from a trajectory segment.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
rewards
|
Float[Array, ' T']
|
Per-step rewards |
required |
dones
|
Bool[Array, ' T']
|
Whether each step ended an episode |
required |
final_value
|
Float[ArrayLike, '']
|
Return used to bootstrap the trajectory boundary |
required |
gamma
|
Float[ArrayLike, '']
|
Discount factor |
required |
Returns:
| Type | Description |
|---|---|
Float[Array, ' T']
|
The discounted returns, with shape |
lerax.advantage.GAE
Bases: AbstractAdvantageEstimator
Generalized Advantage Estimation.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
gamma
|
Float[ArrayLike, '']
|
Discount factor |
0.99
|
lam
|
Float[ArrayLike, '']
|
Bias-variance tradeoff |
0.95
|
Attributes:
| Name | Type | Description |
|---|---|---|
gamma |
Float[ArrayLike, '']
|
Discount factor |
lam |
Float[ArrayLike, '']
|
Bias-variance tradeoff |
lerax.advantage.BootstrappedReturn
Bases: AbstractAdvantageEstimator
Discounted returns bootstrapped at an incomplete segment boundary.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
gamma
|
Float[ArrayLike, '']
|
Discount factor. |
0.99
|
Attributes:
| Name | Type | Description |
|---|---|---|
gamma |
Float[ArrayLike, '']
|
Discount factor. |
lerax.advantage.NStepReturn
Bases: AbstractAdvantageEstimator
N-step bootstrapped returns.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
n
|
int
|
Maximum number of rewards accumulated before bootstrapping. |
required |
gamma
|
Float[ArrayLike, '']
|
Discount factor. |
0.99
|
Attributes:
| Name | Type | Description |
|---|---|---|
n |
int
|
Maximum number of rewards accumulated before bootstrapping. |
gamma |
Float[ArrayLike, '']
|
Discount factor. |