Table of Contents

Class AddWhiteNoise<TObs, TAct>

Namespace
Gym.Wrappers
Assembly
Gym.dll

Replaces each pixel of the rendered frame by white noise with a given probability, as Gymnasium's AddWhiteNoise does; with AddRenderObservation it makes pixel observations noisy, turning the MDP into a POMDP.

public class AddWhiteNoise<TObs, TAct> : Wrapper<TObs, TAct>, IDynamicAttributes, IWrapper, IEnv, IDisposable, IRecordConstructorArgs

Type Parameters

TObs

The observation type, passed through.

TAct

The action type, passed through.

Inheritance
Env<TObs, TAct>
Wrapper<TObs, TAct, TObs, TAct>
Wrapper<TObs, TAct>
AddWhiteNoise<TObs, TAct>
Implements
Inherited Members
Extension Methods

Remarks

Every render draws the noise and then the mask from the env's generator (self.np_random), so rendering advances the env's stream. The frame must be an array (rgb_array). The result is a new array: uint8 for RGB noise, uint64 for grayscale noise (NumPy's sum of uint8 promotes to uint64, and np.where keeps it).

Reference: gymnasium/wrappers/rendering.py.

Constructors

AddWhiteNoise(Env<TObs, TAct>, AddWhiteNoiseOptions)

Builds the instance from its options record: the properties set, the constructor's defaults for the rest.

public AddWhiteNoise(Env<TObs, TAct> env, AddWhiteNoiseOptions options)

Parameters

env Env<TObs, TAct>

The env to wrap.

options AddWhiteNoiseOptions

The options.

Exceptions

ArgumentNullException

Thrown when options is null.

TypeError

Thrown when a required argument is unset, with Python's missing-argument message.

AddWhiteNoise(Env<TObs, TAct>, double, bool)

Wraps env.

public AddWhiteNoise(Env<TObs, TAct> env, double probabilityOfNoisePerPixel, bool isNoiseGrayscale = false)

Parameters

env Env<TObs, TAct>

The env; it must render arrays.

probabilityOfNoisePerPixel double

The probability that a pixel is noise, in [0, 1).

isNoiseGrayscale bool

Whether the noise is gray (the RGB noise weighted and summed) rather than colored.

Exceptions

InvalidProbability

Thrown for a probability outside [0, 1): probability_of_noise_per_pixel should be in the interval [0,1). Received 1.0.

TypeError

Thrown when env is null.

Properties

IsNoiseGrayscale

Whether the noise is gray (is_noise_grayscale).

public bool IsNoiseGrayscale { get; set; }

Property Value

bool

ProbabilityOfNoisePerPixel

The probability that a pixel is noise (probability_of_noise_per_pixel).

public double ProbabilityOfNoisePerPixel { get; set; }

Property Value

double

SavedKwargs

The recorded constructor arguments (Python's _saved_kwargs).

[PyName("_saved_kwargs")]
public Info SavedKwargs { get; }

Property Value

Info

Methods

Render()

The env's frame with noise in place of each pixel the mask picks.

public override RenderResult Render()

Returns

RenderResult

A new frame (RenderResult.Rgb) the caller owns.

Exceptions

AttributeError

Thrown when the env's render is not an array, as Python's render_out.shape raises.