Skip to content
DeepForgeby svx
All problems
MediumComputer Visioncv-379

NeRF Positional Encoding Dimension

Problem

Compute the dimension of NeRF's sinusoidal positional encoding.

Each of the 3 coordinates contributes 2 values (sin and cos) per frequency level, and include_input additionally keeps the 3 raw coordinates. Return 3 if include_input is True plus 6 * levels.

Hint

The encoding is applied to the 3D position, so there are 3 sin/cos pairs per level.

Test cases

case 1
in: [10,true]
expected: 63
case 2
in: [10,false]
expected: 60
case 3
in: [4,true]
expected: 27
case 4
in: [0,true]
expected: 3
Starter codePython
def nerf_pe_dim(levels, include_input):
    # Your code here
    pass

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