Skip to content
DeepForgeby svx
All problems

TD3 Target Smoothing

Problem

Smooth a target action the way TD3 does: add clipped noise and clamp to the valid action range.

Clip noise to [-clip_range, clip_range], add it to action, then clamp the result to [low, high]. Return the smoothed action.

Hint

Clamp the noise first, then clamp the perturbed action.

Test cases

case 1
in: [0.5,0.2,0.1,-1,1]
expected: 0.6
case 2
in: [0.5,-0.5,0.1,-1,1]
expected: 0.4
case 3
in: [0.95,0.3,0.2,-1,1]
expected: 1
case 4
in: [-0.9,-0.3,0.2,-1,1]
expected: -1
Starter codePython
def td3_smooth_target(action, noise, clip_range, low, high):
    # Your code here
    pass

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