Files

60 lines
3.6 KiB
XML
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
<svg width="700" height="260" xmlns="http://www.w3.org/2000/svg">
<defs>
<marker id="res-arrow" markerWidth="8" markerHeight="6" refX="8" refY="3" orient="auto">
<polygon points="0 0, 8 3, 0 6" fill="#555"/>
</marker>
</defs>
<text x="350" y="22" fill="#333" font-size="14" font-weight="bold" text-anchor="middle">ResNet Residual Block</text>
<!-- Input x -->
<rect x="80" y="105" width="60" height="30" rx="6" fill="#3498db" opacity="0.15" stroke="#3498db" stroke-width="1.5"/>
<text x="110" y="125" fill="#3498db" font-size="12" text-anchor="middle" font-weight="bold">x</text>
<!-- Arrow to Conv1 -->
<line x1="140" y1="120" x2="185" y2="120" stroke="#555" stroke-width="1.5" marker-end="url(#res-arrow)"/>
<!-- Conv1 + BN + ReLU -->
<rect x="195" y="90" width="100" height="60" rx="6" fill="#e74c3c" opacity="0.12" stroke="#e74c3c" stroke-width="1.5"/>
<text x="245" y="115" fill="#e74c3c" font-size="10" text-anchor="middle" font-weight="bold">3×3 Conv</text>
<text x="245" y="130" fill="#e74c3c" font-size="9" text-anchor="middle">BN + ReLU</text>
<!-- Arrow to Conv2 -->
<line x1="295" y1="120" x2="325" y2="120" stroke="#555" stroke-width="1.5" marker-end="url(#res-arrow)"/>
<!-- Conv2 + BN -->
<rect x="335" y="90" width="100" height="60" rx="6" fill="#e74c3c" opacity="0.12" stroke="#e74c3c" stroke-width="1.5"/>
<text x="385" y="115" fill="#e74c3c" font-size="10" text-anchor="middle" font-weight="bold">3×3 Conv</text>
<text x="385" y="130" fill="#e74c3c" font-size="9" text-anchor="middle">BN</text>
<!-- Arrow from Conv2 to add -->
<line x1="435" y1="120" x2="478" y2="120" stroke="#555" stroke-width="1.5" marker-end="url(#res-arrow)"/>
<!-- Addition circle -->
<circle cx="498" cy="120" r="18" fill="#27ae60" opacity="0.15" stroke="#27ae60" stroke-width="2"/>
<text x="498" y="126" fill="#27ae60" font-size="18" text-anchor="middle" font-weight="bold">+</text>
<!-- Skip connection (curved path from x to add) -->
<path d="M 110,105 L 110,50 L 498,50 L 498,102" fill="none" stroke="#3498db" stroke-width="2" stroke-dasharray="6,3"/>
<polygon points="495,102 498,95 501,102" fill="#3498db"/>
<text x="300" y="44" fill="#3498db" font-size="11" text-anchor="middle" font-weight="bold">Skip Connection (identity)</text>
<!-- Arrow from add to ReLU -->
<line x1="516" y1="120" x2="548" y2="120" stroke="#555" stroke-width="1.5" marker-end="url(#res-arrow)"/>
<!-- ReLU -->
<rect x="558" y="105" width="50" height="30" rx="6" fill="#f39c12" opacity="0.15" stroke="#f39c12" stroke-width="1.5"/>
<text x="583" y="125" fill="#f39c12" font-size="10" text-anchor="middle" font-weight="bold">ReLU</text>
<!-- Output -->
<line x1="608" y1="120" x2="640" y2="120" stroke="#555" stroke-width="1.5" marker-end="url(#res-arrow)"/>
<text x="665" y="125" fill="#333" font-size="11" text-anchor="middle" font-weight="bold">F(x)+x</text>
<!-- Labels -->
<text x="290" y="170" fill="#e74c3c" font-size="10" text-anchor="middle">F(x) = residual mapping</text>
<!-- Bottom explanation -->
<rect x="100" y="195" width="500" height="50" rx="6" fill="#f5f5f5" stroke="#333" stroke-width="1"/>
<text x="350" y="213" fill="#333" font-size="10" text-anchor="middle">The layer learns F(x) = output x. If the optimal output is close to x,</text>
<text x="350" y="228" fill="#333" font-size="10" text-anchor="middle">learning a near-zero F(x) is much easier than learning the full mapping.</text>
<text x="350" y="241" fill="#666" font-size="9" text-anchor="middle">Gradients flow directly through the skip connection, solving vanishing gradients.</text>
</svg>