summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--doc/CNN_V2.md21
-rwxr-xr-xtraining/gen_identity_weights.py13
2 files changed, 30 insertions, 4 deletions
diff --git a/doc/CNN_V2.md b/doc/CNN_V2.md
index 577cf9e..abef606 100644
--- a/doc/CNN_V2.md
+++ b/doc/CNN_V2.md
@@ -136,6 +136,27 @@ let bias = 1.0; // Learned bias per output channel
// Packed storage: [p0, p1, p2, p3, uv.x, uv.y, sin(20*uv.y), 1.0]
```
+### Input Channel Mapping
+
+**Weight tensor layout (12 input channels per layer):**
+
+| Input Channel | Feature | Description |
+|--------------|---------|-------------|
+| 0-3 | Previous layer output | 4D RGBA from prior CNN layer (or input RGBD for Layer 0) |
+| 4-11 | Static features | 8D: p0, p1, p2, p3, uv_x, uv_y, sin20_y, bias |
+
+**Static feature channel details:**
+- Channel 4 → p0 (RGB.r from mip level)
+- Channel 5 → p1 (RGB.g from mip level)
+- Channel 6 → p2 (RGB.b from mip level)
+- Channel 7 → p3 (depth or RGB channel from mip level)
+- Channel 8 → p4 (uv_x: normalized horizontal position)
+- Channel 9 → p5 (uv_y: normalized vertical position)
+- Channel 10 → p6 (sin(20*uv_y): periodic encoding)
+- Channel 11 → p7 (bias: constant 1.0)
+
+**Note:** When generating identity weights, p4-p7 correspond to input channels 8-11, not 4-7.
+
### Feature Rationale
| Feature | Dimension | Purpose | Priority |
diff --git a/training/gen_identity_weights.py b/training/gen_identity_weights.py
index 5756e67..5d83bfb 100755
--- a/training/gen_identity_weights.py
+++ b/training/gen_identity_weights.py
@@ -7,8 +7,8 @@ Output Ch{0,1,2,3} = Input Ch{0,1,2,3} (ignores static features).
With --mix: Output Ch{i} = 0.5*Input Ch{i} + 0.5*Input Ch{i+4}
(50-50 blend, avoids overflow)
-With --p47: Output Ch{i} = Input Ch{i+4} (static features only)
- (p4→ch0, p5→ch1, p6→ch2, p7→ch3)
+With --p47: Output Ch{i} = static p{4+i} (uv_x, uv_y, sin20_y, bias)
+ (p4/uv_x→ch0, p5/uv_y→ch1, p6/sin20_y→ch2, p7/bias→ch3)
Usage:
./training/gen_identity_weights.py [output.bin]
@@ -26,7 +26,10 @@ def generate_identity_weights(output_path, kernel_size=1, mip_level=0, mix=False
"""Generate identity weights: output = input (ignores static features).
If mix=True, 50-50 blend: 0.5*p0+0.5*p4, 0.5*p1+0.5*p5, etc (avoids overflow).
- If p47=True, transfers p4→p0, p5→p1, p6→p2, p7→p3 (static features only).
+ If p47=True, transfers static p4-p7 (uv_x, uv_y, sin20_y, bias) to output channels.
+
+ Input channel layout: [0-3: prev layer, 4-11: static (p0-p7)]
+ Static features: p0-p3 (RGB+D), p4 (uv_x), p5 (uv_y), p6 (sin20_y), p7 (bias)
Binary format:
Header (20 bytes):
@@ -61,8 +64,10 @@ def generate_identity_weights(output_path, kernel_size=1, mip_level=0, mix=False
if p47:
# p47 mode: p4→ch0, p5→ch1, p6→ch2, p7→ch3 (static features only)
+ # Input channels: [0-3: prev layer, 4-11: static features (p0-p7)]
+ # p4-p7 are at input channels 8-11
for i in range(out_channels):
- weights[i, i + 4, center, center] = 1.0
+ weights[i, i + 8, center, center] = 1.0
elif mix:
# Mix mode: 50-50 blend to avoid overflow
for i in range(out_channels):