-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathalg_quant.tex
More file actions
28 lines (28 loc) · 936 Bytes
/
Copy pathalg_quant.tex
File metadata and controls
28 lines (28 loc) · 936 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
Реализация квантования матрицы весов:
\begin{verbatim}
tic;
quantization_layer = 128;
disp(['start quantization L = '
num2str(quantization_layer)]);
for g = 1 : 4
w_max_str = max(abs(W{1,g}));
w_max = max(abs(w_max_str));
delta = w_max/(quantization_layer - 1);
count = newNN.size(g)+1;
count_2 = newNN.size(g+1);
for d = 1 : count_2
for e = 1 : colich
for k = 1 : quantization_layer
w = abs(W{1,g}(d,e));
if w > (k-1)*delta && w < k*delta
W{1,g}(d,e) =
(k-1)*delta*sign(W{1,g}(d,e));
end
end
end
end
end
time = toc;
disp(['end quantization ' num2str(time)]);
save(['quant_res_' int2str(quantization_layer)],'W');
\end{verbatim}