Spaces:
Running
Running
update
Browse files- .DS_Store +0 -0
- assets/.DS_Store +0 -0
- assets/images/first_steps_memory_profile.js +160 -0
- assets/images/{what_we_learnt_heatmap copy.svg → first_steps_memory_profile.svg} +0 -0
- assets/images/first_steps_simple_training.js +149 -0
- assets/images/first_steps_simple_training.svg +663 -0
- assets/svg/figure-01.svg +0 -3
- assets/svg/test-svg.html +0 -164
- dist/assets/.DS_Store +0 -0
- dist/assets/images/first_steps_memory_profile.js +1 -0
- dist/assets/images/{what_we_learnt_heatmap copy.svg → first_steps_memory_profile.svg} +0 -0
- dist/assets/images/first_steps_simple_training.js +1 -0
- dist/assets/images/first_steps_simple_training.svg +663 -0
- dist/assets/svg/figure-01.svg +0 -3
- dist/assets/svg/test-svg.html +0 -164
- src/index.html +9 -3
.DS_Store
ADDED
Binary file (8.2 kB). View file
|
|
assets/.DS_Store
ADDED
Binary file (6.15 kB). View file
|
|
assets/images/first_steps_memory_profile.js
ADDED
@@ -0,0 +1,160 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
// first_steps_memory_profile.js
|
2 |
+
|
3 |
+
// Function to enhance the SVG content by adding styles and data attributes
|
4 |
+
function enhanceSVGContent2(originalContent) {
|
5 |
+
const parser = new DOMParser();
|
6 |
+
const doc = parser.parseFromString(originalContent, 'image/svg+xml');
|
7 |
+
|
8 |
+
// Create a style element with hover effects and insert it as the first child of the SVG
|
9 |
+
const styleElement = doc.createElementNS('http://www.w3.org/2000/svg', 'style');
|
10 |
+
styleElement.textContent = `
|
11 |
+
/* Memory Block (free memory) */
|
12 |
+
path[data-element-type="memory-block"] {
|
13 |
+
transition: all 0.3s;
|
14 |
+
cursor: pointer;
|
15 |
+
}
|
16 |
+
path[data-element-type="memory-block"]:hover {
|
17 |
+
fill: #a5d6a7 !important; /* slightly darker than original */
|
18 |
+
transform: translate(0, -2px);
|
19 |
+
}
|
20 |
+
|
21 |
+
/* Memory Block (updated) */
|
22 |
+
path[data-element-type="memory-block-updated"] {
|
23 |
+
transition: all 0.3s;
|
24 |
+
cursor: pointer;
|
25 |
+
}
|
26 |
+
path[data-element-type="memory-block-updated"]:hover {
|
27 |
+
fill: #81c784 !important;
|
28 |
+
transform: scale(1.02) translate(0, -2px);
|
29 |
+
}
|
30 |
+
|
31 |
+
/* Stack Segment */
|
32 |
+
path[data-element-type="stack"] {
|
33 |
+
transition: all 0.3s;
|
34 |
+
cursor: pointer;
|
35 |
+
}
|
36 |
+
path[data-element-type="stack"]:hover {
|
37 |
+
fill: #ffd54f !important;
|
38 |
+
transform: translate(0, -2px);
|
39 |
+
}
|
40 |
+
|
41 |
+
/* Read Operation Arrow */
|
42 |
+
path[data-element-type="read"] {
|
43 |
+
transition: all 0.3s;
|
44 |
+
cursor: pointer;
|
45 |
+
}
|
46 |
+
path[data-element-type="read"]:hover {
|
47 |
+
stroke: #1e88e5 !important;
|
48 |
+
stroke-width: 4 !important;
|
49 |
+
}
|
50 |
+
|
51 |
+
/* Write Operation Arrow */
|
52 |
+
path[data-element-type="write"] {
|
53 |
+
transition: all 0.3s;
|
54 |
+
cursor: pointer;
|
55 |
+
}
|
56 |
+
path[data-element-type="write"]:hover {
|
57 |
+
stroke: #d32f2f !important;
|
58 |
+
stroke-width: 4 !important;
|
59 |
+
}
|
60 |
+
|
61 |
+
/* Cache Operation Arrow */
|
62 |
+
path[data-element-type="cache"] {
|
63 |
+
transition: all 0.3s;
|
64 |
+
cursor: pointer;
|
65 |
+
}
|
66 |
+
path[data-element-type="cache"]:hover {
|
67 |
+
stroke: #fbc02d !important;
|
68 |
+
stroke-width: 4 !important;
|
69 |
+
}
|
70 |
+
`;
|
71 |
+
doc.documentElement.insertBefore(styleElement, doc.documentElement.firstChild);
|
72 |
+
|
73 |
+
// Process Memory Blocks (free memory segments) – assume they have fill color "#c8e6c9"
|
74 |
+
doc.querySelectorAll('path[fill="#c8e6c9"]').forEach((node, index) => {
|
75 |
+
node.setAttribute('data-element-id', `memory-block-${index}`);
|
76 |
+
node.setAttribute('data-element-type', 'memory-block');
|
77 |
+
});
|
78 |
+
|
79 |
+
// Process Updated Memory Blocks – assume they have fill color "#a5d6a7"
|
80 |
+
doc.querySelectorAll('path[fill="#a5d6a7"]').forEach((node, index) => {
|
81 |
+
node.setAttribute('data-element-id', `memory-block-updated-${index}`);
|
82 |
+
node.setAttribute('data-element-type', 'memory-block-updated');
|
83 |
+
});
|
84 |
+
|
85 |
+
// Process Stack Segments – assume they have fill color "#ffe082"
|
86 |
+
doc.querySelectorAll('path[fill="#ffe082"]').forEach((node, index) => {
|
87 |
+
node.setAttribute('data-element-id', `stack-${index}`);
|
88 |
+
node.setAttribute('data-element-type', 'stack');
|
89 |
+
});
|
90 |
+
|
91 |
+
// Process arrows for memory operations based on stroke colors
|
92 |
+
// Assume:
|
93 |
+
// stroke "#42a5f5" for read operations,
|
94 |
+
// stroke "#ef5350" for write operations,
|
95 |
+
// stroke "#ffca28" for cache operations.
|
96 |
+
const arrowTypes = {
|
97 |
+
'#42a5f5': 'read',
|
98 |
+
'#ef5350': 'write',
|
99 |
+
'#ffca28': 'cache'
|
100 |
+
};
|
101 |
+
|
102 |
+
Object.entries(arrowTypes).forEach(([color, type]) => {
|
103 |
+
doc.querySelectorAll(`path[stroke="${color}"]`).forEach((arrow, index) => {
|
104 |
+
arrow.setAttribute('data-element-id', `${type}-${index}`);
|
105 |
+
arrow.setAttribute('data-element-type', type);
|
106 |
+
});
|
107 |
+
});
|
108 |
+
|
109 |
+
// Make the SVG responsive
|
110 |
+
doc.documentElement.setAttribute('width', '100%');
|
111 |
+
doc.documentElement.setAttribute('height', '100%');
|
112 |
+
doc.documentElement.setAttribute('preserveAspectRatio', 'xMidYMid meet');
|
113 |
+
|
114 |
+
return new XMLSerializer().serializeToString(doc);
|
115 |
+
}
|
116 |
+
|
117 |
+
// Function to load an SVG file via fetch
|
118 |
+
async function loadSVG(url, containerId) {
|
119 |
+
try {
|
120 |
+
console.log('Loading SVG from:', url);
|
121 |
+
const response = await fetch(url);
|
122 |
+
if (!response.ok) {
|
123 |
+
throw new Error(`HTTP error! Status: ${response.status}`);
|
124 |
+
}
|
125 |
+
const svgText = await response.text();
|
126 |
+
const enhancedSVG = enhanceSVGContent2(svgText);
|
127 |
+
document.getElementById(containerId).innerHTML = enhancedSVG;
|
128 |
+
} catch (error) {
|
129 |
+
console.error('Error loading SVG:', error);
|
130 |
+
document.getElementById(containerId).innerHTML = '<p>Error loading SVG.</p>';
|
131 |
+
}
|
132 |
+
}
|
133 |
+
|
134 |
+
// Load the SVG file (adjust the path if needed)
|
135 |
+
loadSVG('../assets/images/first_steps_memory_profile.svg', 'svg-first_steps_memory_profile');
|
136 |
+
|
137 |
+
// Set up event listeners to display a description of the hovered element
|
138 |
+
const svgContainer2 = document.getElementById('svg-first_steps_memory_profile');
|
139 |
+
|
140 |
+
svgContainer2.addEventListener('mouseover', function(event) {
|
141 |
+
const target = event.target;
|
142 |
+
if (target.tagName.toLowerCase() === 'path' && target.hasAttribute('data-element-id')) {
|
143 |
+
const elementId = target.getAttribute('data-element-id');
|
144 |
+
const elementType = target.getAttribute('data-element-type');
|
145 |
+
const descriptions = {
|
146 |
+
'memory-block': 'Memory Block',
|
147 |
+
'memory-block-updated': 'Memory Block (updated)',
|
148 |
+
'stack': 'Stack Segment',
|
149 |
+
'read': 'Memory Read',
|
150 |
+
'write': 'Memory Write',
|
151 |
+
'cache': 'Cache Operation'
|
152 |
+
};
|
153 |
+
const description = descriptions[elementType] || elementType;
|
154 |
+
document.getElementById('info').textContent = `Hovering over: ${description} (${elementId})`;
|
155 |
+
}
|
156 |
+
});
|
157 |
+
|
158 |
+
svgContainer2.addEventListener('mouseout', function() {
|
159 |
+
document.getElementById('info').textContent = 'Hover over the network elements to see their details';
|
160 |
+
});
|
assets/images/{what_we_learnt_heatmap copy.svg → first_steps_memory_profile.svg}
RENAMED
File without changes
|
assets/images/first_steps_simple_training.js
ADDED
@@ -0,0 +1,149 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
|
2 |
+
// Function to enhance the SVG content by adding styles and data attributes
|
3 |
+
function enhanceSVGContent(originalContent) {
|
4 |
+
const parser = new DOMParser();
|
5 |
+
const doc = parser.parseFromString(originalContent, 'image/svg+xml');
|
6 |
+
|
7 |
+
// Create a style element with hover effects and insert it as the first child of the SVG
|
8 |
+
const styleElement = doc.createElementNS('http://www.w3.org/2000/svg', 'style');
|
9 |
+
styleElement.textContent = `
|
10 |
+
path[data-element-type="layer"] {
|
11 |
+
transition: all 0.3s;
|
12 |
+
cursor: pointer;
|
13 |
+
}
|
14 |
+
path[data-element-type="layer"]:hover {
|
15 |
+
fill: #b197fc !important;
|
16 |
+
transform: translate(0, -2px);
|
17 |
+
}
|
18 |
+
|
19 |
+
path[data-element-type="layer-updated"] {
|
20 |
+
transition: all 0.3s;
|
21 |
+
cursor: pointer;
|
22 |
+
}
|
23 |
+
|
24 |
+
path[data-element-type="layer-updated"]:hover {
|
25 |
+
fill:rgb(103, 56, 244) !important;
|
26 |
+
transform: scale(1.02);
|
27 |
+
transform: translate(0, -2px);
|
28 |
+
}
|
29 |
+
|
30 |
+
path[data-element-type="gradient"] {
|
31 |
+
transition: all 0.3s;
|
32 |
+
cursor: pointer;
|
33 |
+
}
|
34 |
+
path[data-element-type="gradient"]:hover {
|
35 |
+
fill: #f06595 !important;
|
36 |
+
transform: translate(0, -2px);
|
37 |
+
}
|
38 |
+
|
39 |
+
path[data-element-type="forward"] {
|
40 |
+
transition: all 0.3s;
|
41 |
+
cursor: pointer;
|
42 |
+
}
|
43 |
+
path[data-element-type="forward"]:hover {
|
44 |
+
stroke: #0c8599 !important;
|
45 |
+
stroke-width: 4 !important;
|
46 |
+
}
|
47 |
+
|
48 |
+
path[data-element-type="backward"] {
|
49 |
+
transition: all 0.3s;
|
50 |
+
cursor: pointer;
|
51 |
+
}
|
52 |
+
path[data-element-type="backward"]:hover {
|
53 |
+
stroke: #e8590c !important;
|
54 |
+
stroke-width: 4 !important;
|
55 |
+
}
|
56 |
+
|
57 |
+
path[data-element-type="optimization"] {
|
58 |
+
transition: all 0.3s;
|
59 |
+
cursor: pointer;
|
60 |
+
}
|
61 |
+
path[data-element-type="optimization"]:hover {
|
62 |
+
stroke: #087f5b !important;
|
63 |
+
stroke-width: 4 !important;
|
64 |
+
}
|
65 |
+
`;
|
66 |
+
doc.documentElement.insertBefore(styleElement, doc.documentElement.firstChild);
|
67 |
+
|
68 |
+
// Process neural network layers (purple nodes)
|
69 |
+
doc.querySelectorAll('path[fill="#d0bfff"]').forEach((node, index) => {
|
70 |
+
node.setAttribute('data-element-id', `layer-${index}`);
|
71 |
+
node.setAttribute('data-element-type', 'layer');
|
72 |
+
});
|
73 |
+
|
74 |
+
doc.querySelectorAll('path[fill="#9775fa"]').forEach((node, index) => {
|
75 |
+
node.setAttribute('data-element-id', `layer-updated-${index}`);
|
76 |
+
node.setAttribute('data-element-type', 'layer-updated');
|
77 |
+
});
|
78 |
+
|
79 |
+
// Process gradient nodes (pink nodes)
|
80 |
+
doc.querySelectorAll('path[fill="#f783ac"]').forEach((node, index) => {
|
81 |
+
node.setAttribute('data-element-id', `gradient-${index}`);
|
82 |
+
node.setAttribute('data-element-type', 'gradient');
|
83 |
+
});
|
84 |
+
|
85 |
+
// Process arrows by matching stroke colors
|
86 |
+
const arrowTypes = {
|
87 |
+
'#15aabf': 'forward',
|
88 |
+
'#fd7e14': 'backward',
|
89 |
+
'#099268': 'optimization'
|
90 |
+
};
|
91 |
+
|
92 |
+
Object.entries(arrowTypes).forEach(([color, type]) => {
|
93 |
+
doc.querySelectorAll(`path[stroke="${color}"]`).forEach((arrow, index) => {
|
94 |
+
arrow.setAttribute('data-element-id', `${type}-${index}`);
|
95 |
+
arrow.setAttribute('data-element-type', type);
|
96 |
+
});
|
97 |
+
});
|
98 |
+
|
99 |
+
// Make the SVG responsive
|
100 |
+
doc.documentElement.setAttribute('width', '100%');
|
101 |
+
doc.documentElement.setAttribute('height', '100%');
|
102 |
+
doc.documentElement.setAttribute('preserveAspectRatio', 'xMidYMid meet');
|
103 |
+
|
104 |
+
return new XMLSerializer().serializeToString(doc);
|
105 |
+
}
|
106 |
+
|
107 |
+
// Function to load an SVG file via fetch
|
108 |
+
async function loadSVG(url, containerId) {
|
109 |
+
try {
|
110 |
+
const response = await fetch(url);
|
111 |
+
if (!response.ok) {
|
112 |
+
throw new Error(`HTTP error! Status: ${response.status}`);
|
113 |
+
}
|
114 |
+
const svgText = await response.text();
|
115 |
+
const enhancedSVG = enhanceSVGContent(svgText);
|
116 |
+
document.getElementById(containerId).innerHTML = enhancedSVG;
|
117 |
+
} catch (error) {
|
118 |
+
console.error('Error loading SVG:', error);
|
119 |
+
document.getElementById(containerId).innerHTML = '<p>Error loading SVG.</p>';
|
120 |
+
}
|
121 |
+
}
|
122 |
+
|
123 |
+
// Load the SVG file (adjust the path if needed)
|
124 |
+
loadSVG('../assets/images/first_steps_simple_training.svg', 'svg-first_steps_simple_training');
|
125 |
+
|
126 |
+
// Set up event listeners to display a description of the hovered element
|
127 |
+
const svgContainer = document.getElementById('svg-first_steps_simple_training');
|
128 |
+
|
129 |
+
svgContainer.addEventListener('mouseover', function (event) {
|
130 |
+
const target = event.target;
|
131 |
+
if (target.tagName.toLowerCase() === 'path' && target.hasAttribute('data-element-id')) {
|
132 |
+
const elementId = target.getAttribute('data-element-id');
|
133 |
+
const elementType = target.getAttribute('data-element-type');
|
134 |
+
const descriptions = {
|
135 |
+
layer: 'Neural Network Layer',
|
136 |
+
'layer-updated': 'Neural Network Layer (updated)',
|
137 |
+
gradient: 'Gradient Update Layer',
|
138 |
+
forward: 'Forward Pass Connection',
|
139 |
+
backward: 'Backward Pass Connection',
|
140 |
+
optimization: 'Optimization Step'
|
141 |
+
};
|
142 |
+
const description = descriptions[elementType] || elementType;
|
143 |
+
document.getElementById('info').textContent = `Hovering over: ${description} (${elementId})`;
|
144 |
+
}
|
145 |
+
});
|
146 |
+
|
147 |
+
svgContainer.addEventListener('mouseout', function () {
|
148 |
+
document.getElementById('info').textContent = 'Hover over the network elements to see their details';
|
149 |
+
});
|
assets/images/first_steps_simple_training.svg
ADDED
|
assets/svg/figure-01.svg
DELETED
assets/svg/test-svg.html
DELETED
@@ -1,164 +0,0 @@
|
|
1 |
-
<!DOCTYPE html>
|
2 |
-
<html lang="en">
|
3 |
-
<head>
|
4 |
-
<meta charset="UTF-8">
|
5 |
-
<title>Interactive SVG Hover Effect</title>
|
6 |
-
<style>
|
7 |
-
body {
|
8 |
-
font-family: Arial, sans-serif;
|
9 |
-
margin: 20px;
|
10 |
-
background: #f8f9fa;
|
11 |
-
}
|
12 |
-
.svg-container {
|
13 |
-
border: 1px solid #ccc;
|
14 |
-
padding: 10px;
|
15 |
-
border-radius: 8px;
|
16 |
-
background: #fff;
|
17 |
-
}
|
18 |
-
.info {
|
19 |
-
margin-top: 15px;
|
20 |
-
font-size: 16px;
|
21 |
-
color: #555;
|
22 |
-
}
|
23 |
-
</style>
|
24 |
-
</head>
|
25 |
-
<body>
|
26 |
-
<div class="svg-container" id="svg-container-01">
|
27 |
-
<!-- The enhanced SVG will be injected here -->
|
28 |
-
</div>
|
29 |
-
<div class="info" id="info">Hover over the network elements to see their details</div>
|
30 |
-
|
31 |
-
<script>
|
32 |
-
// Function to enhance the SVG content by adding styles and data attributes
|
33 |
-
function enhanceSVGContent(originalContent) {
|
34 |
-
const parser = new DOMParser();
|
35 |
-
const doc = parser.parseFromString(originalContent, 'image/svg+xml');
|
36 |
-
|
37 |
-
// Create a style element with hover effects and insert it as the first child of the SVG
|
38 |
-
const styleElement = doc.createElementNS('http://www.w3.org/2000/svg', 'style');
|
39 |
-
styleElement.textContent = `
|
40 |
-
path[data-element-type="layer"] {
|
41 |
-
transition: all 0.3s;
|
42 |
-
cursor: pointer;
|
43 |
-
}
|
44 |
-
path[data-element-type="layer"]:hover {
|
45 |
-
fill: #b197fc !important;
|
46 |
-
transform: translate(0, -2px);
|
47 |
-
}
|
48 |
-
|
49 |
-
path[data-element-type="gradient"] {
|
50 |
-
transition: all 0.3s;
|
51 |
-
cursor: pointer;
|
52 |
-
}
|
53 |
-
path[data-element-type="gradient"]:hover {
|
54 |
-
fill: #f06595 !important;
|
55 |
-
transform: translate(0, -2px);
|
56 |
-
}
|
57 |
-
|
58 |
-
path[data-element-type="forward"] {
|
59 |
-
transition: all 0.3s;
|
60 |
-
cursor: pointer;
|
61 |
-
}
|
62 |
-
path[data-element-type="forward"]:hover {
|
63 |
-
stroke: #0c8599 !important;
|
64 |
-
stroke-width: 4 !important;
|
65 |
-
}
|
66 |
-
|
67 |
-
path[data-element-type="backward"] {
|
68 |
-
transition: all 0.3s;
|
69 |
-
cursor: pointer;
|
70 |
-
}
|
71 |
-
path[data-element-type="backward"]:hover {
|
72 |
-
stroke: #e8590c !important;
|
73 |
-
stroke-width: 4 !important;
|
74 |
-
}
|
75 |
-
|
76 |
-
path[data-element-type="optimization"] {
|
77 |
-
transition: all 0.3s;
|
78 |
-
cursor: pointer;
|
79 |
-
}
|
80 |
-
path[data-element-type="optimization"]:hover {
|
81 |
-
stroke: #087f5b !important;
|
82 |
-
stroke-width: 4 !important;
|
83 |
-
}
|
84 |
-
`;
|
85 |
-
doc.documentElement.insertBefore(styleElement, doc.documentElement.firstChild);
|
86 |
-
|
87 |
-
// Process neural network layers (purple nodes)
|
88 |
-
doc.querySelectorAll('path[fill="#d0bfff"]').forEach((node, index) => {
|
89 |
-
node.setAttribute('data-element-id', `layer-${index}`);
|
90 |
-
node.setAttribute('data-element-type', 'layer');
|
91 |
-
});
|
92 |
-
|
93 |
-
// Process gradient nodes (pink nodes)
|
94 |
-
doc.querySelectorAll('path[fill="#f783ac"]').forEach((node, index) => {
|
95 |
-
node.setAttribute('data-element-id', `gradient-${index}`);
|
96 |
-
node.setAttribute('data-element-type', 'gradient');
|
97 |
-
});
|
98 |
-
|
99 |
-
// Process arrows by matching stroke colors
|
100 |
-
const arrowTypes = {
|
101 |
-
'#15aabf': 'forward',
|
102 |
-
'#fd7e14': 'backward',
|
103 |
-
'#099268': 'optimization'
|
104 |
-
};
|
105 |
-
|
106 |
-
Object.entries(arrowTypes).forEach(([color, type]) => {
|
107 |
-
doc.querySelectorAll(`path[stroke="${color}"]`).forEach((arrow, index) => {
|
108 |
-
arrow.setAttribute('data-element-id', `${type}-${index}`);
|
109 |
-
arrow.setAttribute('data-element-type', type);
|
110 |
-
});
|
111 |
-
});
|
112 |
-
|
113 |
-
// Make the SVG responsive
|
114 |
-
doc.documentElement.setAttribute('width', '100%');
|
115 |
-
doc.documentElement.setAttribute('height', 'auto');
|
116 |
-
doc.documentElement.setAttribute('preserveAspectRatio', 'xMidYMid meet');
|
117 |
-
|
118 |
-
return new XMLSerializer().serializeToString(doc);
|
119 |
-
}
|
120 |
-
|
121 |
-
// Function to load an SVG file via fetch
|
122 |
-
async function loadSVG(url, containerId) {
|
123 |
-
try {
|
124 |
-
const response = await fetch(url);
|
125 |
-
if (!response.ok) {
|
126 |
-
throw new Error(`HTTP error! Status: ${response.status}`);
|
127 |
-
}
|
128 |
-
const svgText = await response.text();
|
129 |
-
const enhancedSVG = enhanceSVGContent(svgText);
|
130 |
-
document.getElementById(containerId).innerHTML = enhancedSVG;
|
131 |
-
} catch (error) {
|
132 |
-
console.error('Error loading SVG:', error);
|
133 |
-
document.getElementById(containerId).innerHTML = '<p>Error loading SVG.</p>';
|
134 |
-
}
|
135 |
-
}
|
136 |
-
|
137 |
-
// Load the SVG file (adjust the path if needed)
|
138 |
-
loadSVG('figure-01.svg', 'svg-container-01');
|
139 |
-
|
140 |
-
// Set up event listeners to display a description of the hovered element
|
141 |
-
const svgContainer = document.getElementById('svg-container-01');
|
142 |
-
svgContainer.addEventListener('mouseover', function(event) {
|
143 |
-
const target = event.target;
|
144 |
-
if (target.tagName.toLowerCase() === 'path' && target.hasAttribute('data-element-id')) {
|
145 |
-
const elementId = target.getAttribute('data-element-id');
|
146 |
-
const elementType = target.getAttribute('data-element-type');
|
147 |
-
const descriptions = {
|
148 |
-
layer: 'Neural Network Layer',
|
149 |
-
gradient: 'Gradient Update Layer',
|
150 |
-
forward: 'Forward Pass Connection',
|
151 |
-
backward: 'Backward Pass Connection',
|
152 |
-
optimization: 'Optimization Step'
|
153 |
-
};
|
154 |
-
const description = descriptions[elementType] || elementType;
|
155 |
-
document.getElementById('info').textContent = `Hovering over: ${description} (${elementId})`;
|
156 |
-
}
|
157 |
-
});
|
158 |
-
|
159 |
-
svgContainer.addEventListener('mouseout', function() {
|
160 |
-
document.getElementById('info').textContent = 'Hover over the network elements to see their details';
|
161 |
-
});
|
162 |
-
</script>
|
163 |
-
</body>
|
164 |
-
</html>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
dist/assets/.DS_Store
ADDED
Binary file (6.15 kB). View file
|
|
dist/assets/images/first_steps_memory_profile.js
ADDED
@@ -0,0 +1 @@
|
|
|
|
|
1 |
+
function enhanceSVGContent2(e){const t=(new DOMParser).parseFromString(e,"image/svg+xml"),n=t.createElementNS("http://www.w3.org/2000/svg","style");return n.textContent='\n /* Memory Block (free memory) */\n path[data-element-type="memory-block"] {\n transition: all 0.3s;\n cursor: pointer;\n }\n path[data-element-type="memory-block"]:hover {\n fill: #a5d6a7 !important; /* slightly darker than original */\n transform: translate(0, -2px);\n }\n\n /* Memory Block (updated) */\n path[data-element-type="memory-block-updated"] {\n transition: all 0.3s;\n cursor: pointer;\n }\n path[data-element-type="memory-block-updated"]:hover {\n fill: #81c784 !important;\n transform: scale(1.02) translate(0, -2px);\n }\n\n /* Stack Segment */\n path[data-element-type="stack"] {\n transition: all 0.3s;\n cursor: pointer;\n }\n path[data-element-type="stack"]:hover {\n fill: #ffd54f !important;\n transform: translate(0, -2px);\n }\n\n /* Read Operation Arrow */\n path[data-element-type="read"] {\n transition: all 0.3s;\n cursor: pointer;\n }\n path[data-element-type="read"]:hover {\n stroke: #1e88e5 !important;\n stroke-width: 4 !important;\n }\n\n /* Write Operation Arrow */\n path[data-element-type="write"] {\n transition: all 0.3s;\n cursor: pointer;\n }\n path[data-element-type="write"]:hover {\n stroke: #d32f2f !important;\n stroke-width: 4 !important;\n }\n\n /* Cache Operation Arrow */\n path[data-element-type="cache"] {\n transition: all 0.3s;\n cursor: pointer;\n }\n path[data-element-type="cache"]:hover {\n stroke: #fbc02d !important;\n stroke-width: 4 !important;\n }\n ',t.documentElement.insertBefore(n,t.documentElement.firstChild),t.querySelectorAll('path[fill="#c8e6c9"]').forEach(((e,t)=>{e.setAttribute("data-element-id",`memory-block-${t}`),e.setAttribute("data-element-type","memory-block")})),t.querySelectorAll('path[fill="#a5d6a7"]').forEach(((e,t)=>{e.setAttribute("data-element-id",`memory-block-updated-${t}`),e.setAttribute("data-element-type","memory-block-updated")})),t.querySelectorAll('path[fill="#ffe082"]').forEach(((e,t)=>{e.setAttribute("data-element-id",`stack-${t}`),e.setAttribute("data-element-type","stack")})),Object.entries({"#42a5f5":"read","#ef5350":"write","#ffca28":"cache"}).forEach((([e,n])=>{t.querySelectorAll(`path[stroke="${e}"]`).forEach(((e,t)=>{e.setAttribute("data-element-id",`${n}-${t}`),e.setAttribute("data-element-type",n)}))})),t.documentElement.setAttribute("width","100%"),t.documentElement.setAttribute("height","100%"),t.documentElement.setAttribute("preserveAspectRatio","xMidYMid meet"),(new XMLSerializer).serializeToString(t)}async function loadSVG(e,t){try{console.log("Loading SVG from:",e);const n=await fetch(e);if(!n.ok)throw new Error(`HTTP error! Status: ${n.status}`);const r=enhanceSVGContent2(await n.text());document.getElementById(t).innerHTML=r}catch(e){console.error("Error loading SVG:",e),document.getElementById(t).innerHTML="<p>Error loading SVG.</p>"}}loadSVG("../assets/images/first_steps_memory_profile.svg","svg-first_steps_memory_profile");const svgContainer2=document.getElementById("svg-first_steps_memory_profile");svgContainer2.addEventListener("mouseover",(function(e){const t=e.target;if("path"===t.tagName.toLowerCase()&&t.hasAttribute("data-element-id")){const e=t.getAttribute("data-element-id"),n=t.getAttribute("data-element-type"),r={"memory-block":"Memory Block","memory-block-updated":"Memory Block (updated)",stack:"Stack Segment",read:"Memory Read",write:"Memory Write",cache:"Cache Operation"}[n]||n;document.getElementById("info").textContent=`Hovering over: ${r} (${e})`}})),svgContainer2.addEventListener("mouseout",(function(){document.getElementById("info").textContent="Hover over the network elements to see their details"}));
|
dist/assets/images/{what_we_learnt_heatmap copy.svg → first_steps_memory_profile.svg}
RENAMED
File without changes
|
dist/assets/images/first_steps_simple_training.js
ADDED
@@ -0,0 +1 @@
|
|
|
|
|
1 |
+
function enhanceSVGContent(t){const e=(new DOMParser).parseFromString(t,"image/svg+xml"),n=e.createElementNS("http://www.w3.org/2000/svg","style");return n.textContent='\n path[data-element-type="layer"] {\n transition: all 0.3s;\n cursor: pointer;\n }\n path[data-element-type="layer"]:hover {\n fill: #b197fc !important;\n transform: translate(0, -2px);\n }\n\n path[data-element-type="layer-updated"] {\n transition: all 0.3s;\n cursor: pointer;\n }\n \n path[data-element-type="layer-updated"]:hover {\n fill:rgb(103, 56, 244) !important;\n transform: scale(1.02);\n transform: translate(0, -2px);\n }\n\n path[data-element-type="gradient"] {\n transition: all 0.3s;\n cursor: pointer;\n }\n path[data-element-type="gradient"]:hover {\n fill: #f06595 !important;\n transform: translate(0, -2px);\n }\n\n path[data-element-type="forward"] {\n transition: all 0.3s;\n cursor: pointer;\n }\n path[data-element-type="forward"]:hover {\n stroke: #0c8599 !important;\n stroke-width: 4 !important;\n }\n\n path[data-element-type="backward"] {\n transition: all 0.3s;\n cursor: pointer;\n }\n path[data-element-type="backward"]:hover {\n stroke: #e8590c !important;\n stroke-width: 4 !important;\n }\n\n path[data-element-type="optimization"] {\n transition: all 0.3s;\n cursor: pointer;\n }\n path[data-element-type="optimization"]:hover {\n stroke: #087f5b !important;\n stroke-width: 4 !important;\n }\n',e.documentElement.insertBefore(n,e.documentElement.firstChild),e.querySelectorAll('path[fill="#d0bfff"]').forEach(((t,e)=>{t.setAttribute("data-element-id",`layer-${e}`),t.setAttribute("data-element-type","layer")})),e.querySelectorAll('path[fill="#9775fa"]').forEach(((t,e)=>{t.setAttribute("data-element-id",`layer-updated-${e}`),t.setAttribute("data-element-type","layer-updated")})),e.querySelectorAll('path[fill="#f783ac"]').forEach(((t,e)=>{t.setAttribute("data-element-id",`gradient-${e}`),t.setAttribute("data-element-type","gradient")})),Object.entries({"#15aabf":"forward","#fd7e14":"backward","#099268":"optimization"}).forEach((([t,n])=>{e.querySelectorAll(`path[stroke="${t}"]`).forEach(((t,e)=>{t.setAttribute("data-element-id",`${n}-${e}`),t.setAttribute("data-element-type",n)}))})),e.documentElement.setAttribute("width","100%"),e.documentElement.setAttribute("height","100%"),e.documentElement.setAttribute("preserveAspectRatio","xMidYMid meet"),(new XMLSerializer).serializeToString(e)}async function loadSVG(t,e){try{const n=await fetch(t);if(!n.ok)throw new Error(`HTTP error! Status: ${n.status}`);const a=enhanceSVGContent(await n.text());document.getElementById(e).innerHTML=a}catch(t){console.error("Error loading SVG:",t),document.getElementById(e).innerHTML="<p>Error loading SVG.</p>"}}loadSVG("../assets/images/first_steps_simple_training.svg","svg-first_steps_simple_training");const svgContainer=document.getElementById("svg-first_steps_simple_training");svgContainer.addEventListener("mouseover",(function(t){const e=t.target;if("path"===e.tagName.toLowerCase()&&e.hasAttribute("data-element-id")){const t=e.getAttribute("data-element-id"),n=e.getAttribute("data-element-type"),a={layer:"Neural Network Layer","layer-updated":"Neural Network Layer (updated)",gradient:"Gradient Update Layer",forward:"Forward Pass Connection",backward:"Backward Pass Connection",optimization:"Optimization Step"}[n]||n;document.getElementById("info").textContent=`Hovering over: ${a} (${t})`}})),svgContainer.addEventListener("mouseout",(function(){document.getElementById("info").textContent="Hover over the network elements to see their details"}));
|
dist/assets/images/first_steps_simple_training.svg
ADDED
|
dist/assets/svg/figure-01.svg
DELETED
dist/assets/svg/test-svg.html
DELETED
@@ -1,164 +0,0 @@
|
|
1 |
-
<!DOCTYPE html>
|
2 |
-
<html lang="en">
|
3 |
-
<head>
|
4 |
-
<meta charset="UTF-8">
|
5 |
-
<title>Interactive SVG Hover Effect</title>
|
6 |
-
<style>
|
7 |
-
body {
|
8 |
-
font-family: Arial, sans-serif;
|
9 |
-
margin: 20px;
|
10 |
-
background: #f8f9fa;
|
11 |
-
}
|
12 |
-
.svg-container {
|
13 |
-
border: 1px solid #ccc;
|
14 |
-
padding: 10px;
|
15 |
-
border-radius: 8px;
|
16 |
-
background: #fff;
|
17 |
-
}
|
18 |
-
.info {
|
19 |
-
margin-top: 15px;
|
20 |
-
font-size: 16px;
|
21 |
-
color: #555;
|
22 |
-
}
|
23 |
-
</style>
|
24 |
-
</head>
|
25 |
-
<body>
|
26 |
-
<div class="svg-container" id="svg-container-01">
|
27 |
-
<!-- The enhanced SVG will be injected here -->
|
28 |
-
</div>
|
29 |
-
<div class="info" id="info">Hover over the network elements to see their details</div>
|
30 |
-
|
31 |
-
<script>
|
32 |
-
// Function to enhance the SVG content by adding styles and data attributes
|
33 |
-
function enhanceSVGContent(originalContent) {
|
34 |
-
const parser = new DOMParser();
|
35 |
-
const doc = parser.parseFromString(originalContent, 'image/svg+xml');
|
36 |
-
|
37 |
-
// Create a style element with hover effects and insert it as the first child of the SVG
|
38 |
-
const styleElement = doc.createElementNS('http://www.w3.org/2000/svg', 'style');
|
39 |
-
styleElement.textContent = `
|
40 |
-
path[data-element-type="layer"] {
|
41 |
-
transition: all 0.3s;
|
42 |
-
cursor: pointer;
|
43 |
-
}
|
44 |
-
path[data-element-type="layer"]:hover {
|
45 |
-
fill: #b197fc !important;
|
46 |
-
transform: translate(0, -2px);
|
47 |
-
}
|
48 |
-
|
49 |
-
path[data-element-type="gradient"] {
|
50 |
-
transition: all 0.3s;
|
51 |
-
cursor: pointer;
|
52 |
-
}
|
53 |
-
path[data-element-type="gradient"]:hover {
|
54 |
-
fill: #f06595 !important;
|
55 |
-
transform: translate(0, -2px);
|
56 |
-
}
|
57 |
-
|
58 |
-
path[data-element-type="forward"] {
|
59 |
-
transition: all 0.3s;
|
60 |
-
cursor: pointer;
|
61 |
-
}
|
62 |
-
path[data-element-type="forward"]:hover {
|
63 |
-
stroke: #0c8599 !important;
|
64 |
-
stroke-width: 4 !important;
|
65 |
-
}
|
66 |
-
|
67 |
-
path[data-element-type="backward"] {
|
68 |
-
transition: all 0.3s;
|
69 |
-
cursor: pointer;
|
70 |
-
}
|
71 |
-
path[data-element-type="backward"]:hover {
|
72 |
-
stroke: #e8590c !important;
|
73 |
-
stroke-width: 4 !important;
|
74 |
-
}
|
75 |
-
|
76 |
-
path[data-element-type="optimization"] {
|
77 |
-
transition: all 0.3s;
|
78 |
-
cursor: pointer;
|
79 |
-
}
|
80 |
-
path[data-element-type="optimization"]:hover {
|
81 |
-
stroke: #087f5b !important;
|
82 |
-
stroke-width: 4 !important;
|
83 |
-
}
|
84 |
-
`;
|
85 |
-
doc.documentElement.insertBefore(styleElement, doc.documentElement.firstChild);
|
86 |
-
|
87 |
-
// Process neural network layers (purple nodes)
|
88 |
-
doc.querySelectorAll('path[fill="#d0bfff"]').forEach((node, index) => {
|
89 |
-
node.setAttribute('data-element-id', `layer-${index}`);
|
90 |
-
node.setAttribute('data-element-type', 'layer');
|
91 |
-
});
|
92 |
-
|
93 |
-
// Process gradient nodes (pink nodes)
|
94 |
-
doc.querySelectorAll('path[fill="#f783ac"]').forEach((node, index) => {
|
95 |
-
node.setAttribute('data-element-id', `gradient-${index}`);
|
96 |
-
node.setAttribute('data-element-type', 'gradient');
|
97 |
-
});
|
98 |
-
|
99 |
-
// Process arrows by matching stroke colors
|
100 |
-
const arrowTypes = {
|
101 |
-
'#15aabf': 'forward',
|
102 |
-
'#fd7e14': 'backward',
|
103 |
-
'#099268': 'optimization'
|
104 |
-
};
|
105 |
-
|
106 |
-
Object.entries(arrowTypes).forEach(([color, type]) => {
|
107 |
-
doc.querySelectorAll(`path[stroke="${color}"]`).forEach((arrow, index) => {
|
108 |
-
arrow.setAttribute('data-element-id', `${type}-${index}`);
|
109 |
-
arrow.setAttribute('data-element-type', type);
|
110 |
-
});
|
111 |
-
});
|
112 |
-
|
113 |
-
// Make the SVG responsive
|
114 |
-
doc.documentElement.setAttribute('width', '100%');
|
115 |
-
doc.documentElement.setAttribute('height', 'auto');
|
116 |
-
doc.documentElement.setAttribute('preserveAspectRatio', 'xMidYMid meet');
|
117 |
-
|
118 |
-
return new XMLSerializer().serializeToString(doc);
|
119 |
-
}
|
120 |
-
|
121 |
-
// Function to load an SVG file via fetch
|
122 |
-
async function loadSVG(url, containerId) {
|
123 |
-
try {
|
124 |
-
const response = await fetch(url);
|
125 |
-
if (!response.ok) {
|
126 |
-
throw new Error(`HTTP error! Status: ${response.status}`);
|
127 |
-
}
|
128 |
-
const svgText = await response.text();
|
129 |
-
const enhancedSVG = enhanceSVGContent(svgText);
|
130 |
-
document.getElementById(containerId).innerHTML = enhancedSVG;
|
131 |
-
} catch (error) {
|
132 |
-
console.error('Error loading SVG:', error);
|
133 |
-
document.getElementById(containerId).innerHTML = '<p>Error loading SVG.</p>';
|
134 |
-
}
|
135 |
-
}
|
136 |
-
|
137 |
-
// Load the SVG file (adjust the path if needed)
|
138 |
-
loadSVG('figure-01.svg', 'svg-container-01');
|
139 |
-
|
140 |
-
// Set up event listeners to display a description of the hovered element
|
141 |
-
const svgContainer = document.getElementById('svg-container-01');
|
142 |
-
svgContainer.addEventListener('mouseover', function(event) {
|
143 |
-
const target = event.target;
|
144 |
-
if (target.tagName.toLowerCase() === 'path' && target.hasAttribute('data-element-id')) {
|
145 |
-
const elementId = target.getAttribute('data-element-id');
|
146 |
-
const elementType = target.getAttribute('data-element-type');
|
147 |
-
const descriptions = {
|
148 |
-
layer: 'Neural Network Layer',
|
149 |
-
gradient: 'Gradient Update Layer',
|
150 |
-
forward: 'Forward Pass Connection',
|
151 |
-
backward: 'Backward Pass Connection',
|
152 |
-
optimization: 'Optimization Step'
|
153 |
-
};
|
154 |
-
const description = descriptions[elementType] || elementType;
|
155 |
-
document.getElementById('info').textContent = `Hovering over: ${description} (${elementId})`;
|
156 |
-
}
|
157 |
-
});
|
158 |
-
|
159 |
-
svgContainer.addEventListener('mouseout', function() {
|
160 |
-
document.getElementById('info').textContent = 'Hover over the network elements to see their details';
|
161 |
-
});
|
162 |
-
</script>
|
163 |
-
</body>
|
164 |
-
</html>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
src/index.html
CHANGED
@@ -48,7 +48,7 @@
|
|
48 |
</div>
|
49 |
</d-title>
|
50 |
<d-byline></d-byline>
|
51 |
-
|
52 |
<d-contents>
|
53 |
</d-contents>
|
54 |
|
@@ -232,7 +232,10 @@
|
|
232 |
<aside>As we’ll see later, these steps may be repeated or intertwined but for now we’ll start simple.</aside>
|
233 |
|
234 |
<p>It looks generally like this: </p>
|
235 |
-
|
|
|
|
|
|
|
236 |
|
237 |
<p>In this figure, the boxes on the top line can be seen as successive layers inside a model (same for the last line). The red boxes are the associated gradients for each of these layers, computed during the backward pass.</p>
|
238 |
|
@@ -294,7 +297,10 @@
|
|
294 |
|
295 |
<p>Using this snippet [TODO: link to appendix A5], we can understand how memory is allocated throughout training. We can see that memory utilization is not a static thing but varies a lot during training and during a training step:</p>
|
296 |
|
297 |
-
<
|
|
|
|
|
|
|
298 |
|
299 |
<p>Clearly the first step looks very different from the subsequent ones, but let’s first have a look at the general anatomy of a step: first the activations increase quickly as we do the forward pass, then during the backward pass the gradients build up and as the backward pass propagates, the stored activations used to compute the gradients are progressively cleared. Finally, we perform the optimization step during which we need all the gradients and then update the optimizer states before we start the next forward pass. </p>
|
300 |
|
|
|
48 |
</div>
|
49 |
</d-title>
|
50 |
<d-byline></d-byline>
|
51 |
+
<d-article>
|
52 |
<d-contents>
|
53 |
</d-contents>
|
54 |
|
|
|
232 |
<aside>As we’ll see later, these steps may be repeated or intertwined but for now we’ll start simple.</aside>
|
233 |
|
234 |
<p>It looks generally like this: </p>
|
235 |
+
|
236 |
+
<div class="svg-container" id="svg-first_steps_simple_training"> </div>
|
237 |
+
<div class="info" id="info">Hover over the network elements to see their details</div>
|
238 |
+
<script src="../assets/images/first_steps_simple_training.js"></script>
|
239 |
|
240 |
<p>In this figure, the boxes on the top line can be seen as successive layers inside a model (same for the last line). The red boxes are the associated gradients for each of these layers, computed during the backward pass.</p>
|
241 |
|
|
|
297 |
|
298 |
<p>Using this snippet [TODO: link to appendix A5], we can understand how memory is allocated throughout training. We can see that memory utilization is not a static thing but varies a lot during training and during a training step:</p>
|
299 |
|
300 |
+
<div class="svg-container l-body-outset" id="svg-first_steps_memory_profile"> </div>
|
301 |
+
<script src="../assets/images/first_steps_memory_profile.js"></script>
|
302 |
+
|
303 |
+
<!-- <p><img alt="llama-1b-memory.png" src="assets/images/placeholder.png" /></p> -->
|
304 |
|
305 |
<p>Clearly the first step looks very different from the subsequent ones, but let’s first have a look at the general anatomy of a step: first the activations increase quickly as we do the forward pass, then during the backward pass the gradients build up and as the backward pass propagates, the stored activations used to compute the gradients are progressively cleared. Finally, we perform the optimization step during which we need all the gradients and then update the optimizer states before we start the next forward pass. </p>
|
306 |
|