Skip to content

Commit

Permalink
FrequencyEncoding clarify docs and fix code-side comment
Browse files Browse the repository at this point in the history
  • Loading branch information
Tom94 committed Apr 19, 2023
1 parent 5d076fe commit 6f0cedb
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 6 deletions.
2 changes: 1 addition & 1 deletion DOCUMENTATION.md
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ Allows composing multiple encodings. The following example replicates the Neural

From NeRF [[Mildenhall et al. 2020]](https://www.matthewtancik.com/nerf). Works better than OneBlob encoding if the dynamic range of the encoded dimension is high. However, suffers from stripe artifacts.

The number of encoded dimensions is twice the specified number of frequencies for each input dimension.
The number of encoded dimensions is twice the specified number of frequencies for each input dimension. E.g. with `n_frequencies == 4`, an input dimension `x` becomes `sin(πx), cos(πx), sin(2πx), cos(2πx), sin(4πx), cos(4πx), sin(8πx), cos(8πx)`.

```json5
{
Expand Down
8 changes: 3 additions & 5 deletions include/tiny-cuda-nn/encodings/frequency.h
Original file line number Diff line number Diff line change
Expand Up @@ -65,17 +65,15 @@ __global__ void frequency_encoding(
* frequency-encoded input dimension 0
* frequency-encoded input dimension 1
* frequency-encoded input dimension ...
* passthrough inputs
* padding (value 1.f)
*/
if (j >= fan_out_encoded) {
data_out(j, i) = 1;
} else {
/* Layout of encoded features (e.g. when inputs abcd.. are XYZ positions):
* sin(a.x), cos(a.x) sin(2pi a.x), cos(2pi a.x) sin(4pi a.x) ...
* sin(a.y), cos(a.y) sin(2pi a.y), cos(2pi a.y) sin(4pi a.y) ...
* sin(a.z), cos(a.z) sin(2pi a.z), cos(2pi a.z) sin(4pi a.z) ...
* (passthrough features)
* sin(pi a.x), cos(pi a.x) sin(2pi a.x), cos(2pi a.x) sin(4pi a.x) ...
* sin(pi a.y), cos(pi a.y) sin(2pi a.y), cos(2pi a.y) sin(4pi a.y) ...
* sin(pi a.z), cos(pi a.z) sin(2pi a.z), cos(2pi a.z) sin(4pi a.z) ...
* (padding)
*/
const uint32_t encoded_input_feature_i = j / (n_frequencies * 2);
Expand Down

0 comments on commit 6f0cedb

Please sign in to comment.