Skip to content

BernoulliBandit-misc

BernoulliBandit

Bases: Environment[EnvState, EnvParams]

Find and exploit the better of two Bernoulli arms within an episode.

Two-armed Bernoulli bandit for meta-learning as in Wang et al. (2017). At every reset one arm is assigned the reward probability params.reward_prob and the other 1 - params.reward_prob, with the assignment chosen uniformly at random. The probabilities stay fixed for the whole episode.

  • Observation: Box of shape (4,) with the last reward, the one-hot encoded last action and the time step (normalized if params.normalize_time).
  • Actions: Discrete(2). The index of the arm to pull.
  • Reward: 1 with the reward probability of the pulled arm, otherwise 0.
  • Termination: never.
  • Truncation: after params.max_steps_in_episode steps (100 by default).
References

Parameters and state

EnvParams

Bases: EnvParams

Parameters of the BernoulliBandit environment.

Attributes:

  • reward_prob (float) –

    Reward probability of one arm. The other arm pays out with probability 1 - reward_prob.

  • normalize_time (bool) –

    Whether the time step in the observation is rescaled to [min_lim, max_lim] instead of given as a raw step count.

  • max_steps_in_episode (float) –

    Number of steps after which the episode is truncated.

  • min_lim (float) –

    Normalized time value at step 0.

  • max_lim (float) –

    Normalized time value at step t_max.

  • t_max (int) –

    Step count that is mapped to max_lim by the time normalization.

EnvState

Bases: EnvState

State of the BernoulliBandit environment.

Attributes:

  • last_action (Array) –

    Arm pulled in the previous step (0 after a reset).

  • last_reward (Array) –

    Reward received in the previous step (0 after a reset).

  • exp_reward_best (Array) –

    Reward probability of the better arm.

  • reward_probs (Array) –

    Array of shape (2,) with the reward probability of each arm.

  • time (float) –

    Number of steps taken in the current episode.