Skip to content
DeepForgeby svx
All problems

TD3 Target Noise Sample

Problem

Sample the clipped target-policy noise that TD3 adds when smoothing the critic target.

Draw one Gaussian sample N(0, sigma) with rng = random.Random(seed), then clamp it to [-clip_range, clip_range]. sigma is positive and the seed makes the sample reproducible.

Hint

Clipping the target noise keeps the smoothed bootstrap value close to the true one.

Test cases

case 1
in: [0.2,0.5,42]
expected: -0.028818065915585674
case 2
in: [0.2,0.5,0]
expected: 0.1883430809361329
case 3
in: [1,0.1,7]
expected: -0.1
case 4
in: [0.3,0.2,123]
expected: 0.12126852996739997
Starter codePython
import random
def td3_target_noise_sample(sigma, clip_range, seed):
    # Your code here
    pass

4 test cases · run your code against them in the editor