https://dl.acm.org/doi/pdf/10.1145/3528223.3530127
https://github.com/nvlabs/instant-ngp
Instant Neurla Graphics Primitives (with a multiresolution Hash Encoding)
- Feature Encoding에 있어서 multi-resolution hash encoding을 제안
- 빠른속도로 Rendering하는 것에 유의미한 결과를 냄
Introduction
Computer Graphics Primitive(Mesh, Spere 등)의 표현에 있어서 전통적인 mathematical 방식→ MLP를 사용한 방식으로의 전환이 일어나는 중.
MLP를 사용하는 방식의 대부분에서 중요한 부분은 input을 higher dimension space로 mapping하는 것 (Feature Encoding).
기존의 MLP approach는 heuristic한 방식이나 structural modification에 의존하여 training process를 복잡하게 하거나 연산량이 너무 많아 GPU의 performance를 제한하는 한계가 존재.
⇒ 따라서 multiresolution hash encoding을 사용하여 adaptive하고 efficient 한 encoding이 가능하도록 함
오직 두 가지 value만을 사용; number of parameter T(1)와 desired finest resolution N_max(2)
Adaptivity
- Grid를, 고정된 사이즈의 feature vector array에 매핑
- coarse resolution에서는 grid point와 array entry 간 1:1 mapping
- fine resolution에서는 array를 hash table로 취급 → 여러개의 grid point가 array entry에 매핑됨 (hash collision)
- 이러한 hash collision이 hash table로 하여금 자동으로 sparse area에 가장 중요한 fine scale detail에 우선순위를 두도록 만듦.
Efficiency
- Hash table lookup이 O(1)만의 시간이 걸리기 때문에 모든 resolution에 있어서 병렬처리에 적용이 가능 (GPU limitation의 해소)
+) NeRF뿐만 아니라 Gigapixel Image, Neural SDF(Signed Distance Function), Neural Radiance Caching(NRC) 등의 여러 Task에서 Multiresolution Hash Encoding을 평가
Related Works
Frequency Encoding
- 보통의 nn은 sin cos 함수로 input encoding하는 방식을 취함 (attention component. transformer에서 주로 채택하는 방식)
$enc(x) = (sin(2^{0}x),sin(2^{1}x),...,sin(2^{L-1}x),cos(2^{0}x),cos(2^{1}x),...,cos(2^{L-1}x))$
- NeRF는 5가지의 input(xyzθΦ) 각각이 독립적으로 encoding됨
Parametric Encoding
- grid나 tree와 같은 보조적인 data structure에 추가적인 parameter를 부여하는 방식 → input vector x에 따라 해당 parameter를 look-up하거나 interpolate하기도 함
- Computational Cost를 얻는 반면 Memory는 커짐. (Fixed input encoding에 비해서 총 parameter 개수는 더 많지만, 필요한 memory access나 FLOP의 수는 유의하게 커지지 않음)
- MLP 크기를 줄임으로써 quality를 크게 저감시키지 않으면서 빠른 convergence가 가능하도록 함.
⇒ Accuracy 면에서 non-parametric 방식에 비해 더 좋은 성능을 내지만 efficiency와 유연성 측면에서 단점이 존재
Sparse Parameteric Encodings
- dense grid를 사용했을 때 단점: empty space에도 많은 feature를 할당함(→ 더 많은 parameter 개수로 이어짐)
- dense grid에서 사용되지 않은 feature를 뽑아냄
Hash Table (논문에서 제안하는 방식)✨✨✨
- 서로 다른 해상도에 인덱싱된 multiple separate spatial hash table에 feature vector를 저장
- Hash Table의 크기는 Hyperparameter로서 reconstruction quality를 위한 parameter의 수를 결정
- encoding output은 interpolate되어, MLP에 넣어지기 전 concat됨
- 더 적은 파라미터 수로 dense grid encoding에 상응하는 질의 reconstruction을 구현
- hash function의 collision을 probing/bucketing/chaining과 같은 explicit한 방식에 맡기지 않음→ 대신 neural network로 하여금 disambiguate hash collision 자체를 배우도록 함.
- Tree 같은 구조에서는 caching이 어려운 반면 hash table 형태를 사용하여 cache size와 같은 구조적인 detail을 조정할 수 있게 함.
Multi-Resolution Hash Encoding
$$ m(y; \Phi) $$
fc neural network m이 주어졌을 때, 우리가 구하고자 하는 것은 그 네트워크의 input에 대한 encoding값임.
$$ y = enc(x; \theta) $$
다시, neural network의 input을 encoding하므로, 결과적으로 네트워크 입장에서는 아래의 weight parameter를 모두 구해야 하는 것이 됨.
$$ \Phi, \theta $$
이 파라미터들은 L resolution levels로 정리되며, 각 level은 최대 T의 feature vector와 F dimensionality를 갖게 됨.
✔ Multi Resolution Hash Encoding의 다섯 단계 알고리즘
(1) Hashing of Voxel Vertices
- 좌표 x가 주어졌을 때, L resolution에 있어서(그림에서 빨간색과 파란색은 서로 다른 resolution을 의미) 주변 voxel을 찾음
- L level의 resolution(N_l)은 coarsest한 resolution(N_min)과 finest resolution(N_max) 사이에 결정됨; level에 따라 growth factor b의 값이 다르게 적용되어 결과적으로 level마다 다른 resolution을 지니게 되는 것.
$N_{l}:= \lfloor N_{min} \cdot b \rfloor, \\ b:= exp({ln N_{max} - ln N_{min} \over L-1})$
- input coordinate x의 주변 값 (그림의 빨간색과 파란색 사각형의 모서리)이 level의 grid resolution에 따라 정해지게 되는 것.
$\lfloor x_{l} \rfloor:=\lfloor x \cdot N_{l}\rfloor, \lceil x_{l} \rceil := \lceil x \cdot N_{l} \rceil$
- 각 코너를 hashing함으로써 index를 부여함
- 2차원 데이터에 대해서는 4개의 코너에 대한 indice가, 3차원 데이터에 대해서는 8개의 코너에 대한 indice가 hashing될 것.
(2) Lookup
- corner indices각각에 대해서, 대응하는 F-dimensional feature vector를 Hash Table에서 찾음 (2번 그림에서 각 모서리에 대응하는 Hash값을 찾는 것을 확인)
- coarse resolution에 대해서는 1대1 대응 ← feature vector array의 최대 크기인 T를 넘지 않기 때문
- fine resolution에 대해서는 hash function에 따라 매핑 (T size)⇒ 대신 array의 적정한 sparse detail을 저장하기 위해 gradient-based optimization에 의존(Implicit hash collision resolution 참고)
⇒ 또한 collision resolution 처리를 위해 subsequent neural network m에 의존
⇒ explicit collision handling이 없음
- 돌아보면, 네트워크 m 입장에서 trainable encoding parameter θ의 공간복잡도는 O(T)가 될 것이고, T⋅L⋅F에 의해 bound될 것임을 알 수 있음 (아래 Spatial Hashing Function 참고)
$h(\mathbf{x}) = \left( \bigoplus_{i=1}^{d} x_i \pi_i \right) \mod T$
- ⊕는 bit-wise XOR operation/d는 dimension/𝜋는 dimension마다 부여된 소수/T는 hash table의 크기
- 해당 hash function은 각 level마다 1개씩 정의됨.
(3) Linear Interpolation
- lookup한 feature를, x의 상대적인 position에 따라서 linearly interpolation; 이때 각 l-번째 voxel 범위 안에서 interpolate 를 진행함.
- 여기서 상대적인 position은, corner로 상정된 resolution 단위 안에서의 x의 상대 위치를 (3번 그림의 x 위치 확인); lower bound로부터 얼마나 떨어져있는지가 interpolation weight가 됨.
$w_{l} := x_{l} - \lfloor x_{l} \rfloor$
(4) Concatenation
- hash function에 따라 lookup하고 interpolate한 feature vector(각 level별로 hash function이 따로 정의되어있음)를 concat하는 과정.
- 이 때 auxiliary input(encoded view direction과 neural radiance caching상의 texture)도 함께 concat하여 최종 MLP input y를 생성.
(5) Neural Network
- Encoding한 input을 MLP에 통과시키기.
(+) Backpropagation
- MLP 입장에서는 hash table 기반의 feature vector와 rendering parameter 모두를 학습하는 것.
- hash function을 거친 후 얻어낸 feature vector→ 그 이후의 과정은 모두 미분가능한 것을 확인가능.
논문에서 고려해본 것들
1. Trade-Off
T size
- T size가 커질수록 quality가 올라가고 performance는 낮아짐; memory는 상응하여 linear하게 증가.
Hyperparameter L(number of Levels) and F(number of feature dimensions)-
- 논문에서는 F=2, L=16이 최적 조합임을 제시
2. Implicit Hash Collision Resolution
- corner indice를 hash로 mapping하는 과정에서 hash collision이 발생할 수 있음 (서로 다른 corner point integer가 같은 table entry를 가리키는 현상)
coarse resolution level
- Hash Table 크기보다 작기 때문에 1:1 mapping되어 collision 발생X
fine resolution level
- bit-wise hash function으로 mapping; space에 걸쳐 pseudo-randomly scatter하기 때문에, point pair가 주어졌을 때 통계적으로 모든 level 에서 해당 사건이 일어날 확률이 거의 없음.
- collision이 일어났을 경우, 충돌이 일어난 corner간에 gradient average가 일어남 ← e.g. radiance field에서 눈에 보이는(표면) point가 그렇지 않은 point보다 recontructed image에 영향을 크게 미칠 것. 더 중요한 샘플의 gradient가 collision average에서 우세할 것이며 결과적으로 higher-weighted point에 hash table entry가 최적화될 것이라는 말.
⇒ Coarse Grid에 대해서 collision이 일어나지 않도록 세팅함으로써 어느정도의 rendering 정확도를 보장하며, fine resolution grid에 대해서도 explicit한 방식에 의존하는 대신 gradient-based optimization에 맡김으로써 detail이 살아있고 정확한 rendering이 가능하게 했다는 것이 요점.
3. Online Adaptivity
- finer grid level로 들어갈 수록 더 작은 region에 대해서 집중 ⇒ 더 적은 collision을 겪게 될 것; 결과적으로 더 정확한 function을 학습하게 됨.
- multiresolution hash encoding이 training data distribution에 자동적으로 adapt되는 효과.
- data structure 유지를 위해서 훈련 도중 discrete jump를 일으키게 될 가능성이 없음→ online training에 있어 강점
4. D-Linear Interpolation
- hash table entry interpolation은 MLP와 encoding 값 y(=enc(x;θ))모두 연속임을 보장함
- Interpolation 없이는 output에 grid-aligned discontinuity가 존재할 것 → rendering 결과에서 blocky한 output으로 이어질 것
Experiments
여러 Task에서 hash encoding적용하여 기존 모델과 비교
Gigapixel Image Approximation
- High Frequency Detail에 강한지 확인하기 위한 2D rendering Task
- ACORN(36.9 h)에 비해 매우 빠른 속도의 training(2.5 min)
Signed Distance Functions (SDF)
- NGLOD와 비교하였을 때 비슷한 수준의 fidelity를 보임 (mIoU)
- 그림자진 model로 시각화하여 비교했더니 예상치 못한 microstructure가 생기는 것을 관찰. multiresolution hash encoding의 hash collision 때문에 발생한 것으로 추측
Neural Radiance Caching
- Triangle wave encoding과 비교
- 짧은 시간(0.7ms)안에 sharper reconstruction이 가능함을 증명/같은 화질에서 FPS 줄임
Neural Radiance and Density Fields (NeRF)✨✨✨
- hash encoding을 사용하지 않은 NeRF 비교군들은 수 시간의 training time이 필요했던 반면 Hash encoding사용 시 학습시간이 1초~5분까지 줄어듦
- 15초~1분-5분정도의 training 시간이 지났을 때 타 모델의 PSNR에 상응하는 결과를 얻어냄
- 특정 geometrix detail에 있어 우수한 성능을 냄