UOMOP

CBS activated layer 본문

DE/Graph

CBS activated layer

Happy PinGu 2024. 9. 3. 18:23
plot_flops(512, 40);


function plot_flops(dim, snr)
    % 데이터 초기화
    full_data = [
        512, 40, 18, 1, 0, 57, 9942;
        512, 40, 19, 1, 1, 132, 9866;
        512, 40, 20, 3, 4, 297, 9696;
        512, 40, 21, 10, 10, 699, 9281;
        512, 40, 22, 33, 61, 1287, 8619;
        512, 40, 23, 110, 179, 2031, 7680;
        512, 40, 24, 321, 396, 2876, 6407;
        512, 40, 25, 774, 724, 3478, 5024;
        512, 40, 26, 1541, 1091, 3648, 3720;
        512, 40, 27, 2698, 1427, 3269, 2606;
        512, 40, 28, 4091, 1591, 2546, 1772;
        512, 40, 29, 5556, 1503, 1843, 1098;
        512, 40, 30, 6882, 1264, 1218, 636;

        512, 20, 18, 1, 5, 130, 9864;
        512, 20, 19, 7, 12, 291, 9690;
        512, 20, 20, 21, 28, 645, 9306;
        512, 20, 21, 98, 99, 1212, 8591;
        512, 20, 22, 294, 222, 1948, 7536;
        512, 20, 23, 808, 368, 2630, 6194;
        512, 20, 24, 1743, 557, 3008, 4692;
        512, 20, 25, 3139, 682, 2878, 3301;
        512, 20, 26, 4771, 792, 2252, 2185;
        512, 20, 27, 6409, 678, 1595, 1318;
        512, 20, 28, 7759, 516, 1007, 718;
        512, 20, 29, 8660, 403, 559, 378;
        512, 20, 30, 9287, 250, 272, 191;

        256, 40, 18, 1, 7, 77, 9915;
        256, 40, 19, 8, 16, 190, 9786;
        256, 40, 20, 39, 34, 410, 9517;
        256, 40, 21, 137, 123, 765, 8975;
        256, 40, 22, 397, 283, 1224, 8096;
        256, 40, 23, 941, 485, 1686, 6888;
        256, 40, 24, 1819, 803, 1885, 5493;
        256, 40, 25, 3179, 937, 1792, 4092;
        256, 40, 26, 4677, 983, 1464, 2876;
        256, 40, 27, 6149, 867, 1072, 1912;
        256, 40, 28, 7377, 748, 703, 1172;
        256, 40, 29, 8287, 611, 422, 680;
        256, 40, 30, 8992, 386, 226, 396;

        256, 20, 18, 6, 12, 189, 9793;
        256, 20, 19, 30, 43, 396, 9531;
        256, 20, 20, 126, 122, 728, 9024;
        256, 20, 21, 406, 322, 1128, 8144;
        256, 20, 22, 1057, 585, 1472, 6886;
        256, 20, 23, 2169, 862, 1584, 5385;
        256, 20, 24, 3755, 974, 1391, 3880;
        256, 20, 25, 5407, 942, 1058, 2593;
        256, 20, 26, 6917, 747, 761, 1575;
        256, 20, 27, 8123, 560, 443, 874;
        256, 20, 28, 8905, 379, 246, 470;
        256, 20, 29, 9425, 211, 131, 233;
        256, 20, 30, 9702, 116, 79, 103;

    ];

    % 상수 정의
    Lv1_weight = 5.602;
    Lv2_weight = 4.789;
    Lv3_weight = 3.807;
    Lv4_weight = 3.23;

    % 주어진 dim과 snr에 해당하는 데이터 필터링
    data = full_data(full_data(:,1) == dim & full_data(:,2) == snr, 3:end);

    % 데이터 필터링 및 FLOPs 계산
    targetPSNR = data(:, 1);
    Lv1 = data(:, 2);
    Lv2 = data(:, 3);
    Lv3 = data(:, 4);
    Lv4 = data(:, 5);
    
    Lv4_FLOPs = Lv4 * Lv4_weight;
    Lv3_FLOPs = Lv3 * Lv3_weight;
    Lv2_FLOPs = Lv2 * Lv2_weight;
    Lv1_FLOPs = Lv1 * Lv1_weight;

    % 모든 FLOPs를 하나의 행렬로 결합
    flopsData = [Lv4_FLOPs, Lv3_FLOPs, Lv2_FLOPs, Lv1_FLOPs];

    % Compression Ratio 설정
    if dim == 512
        cr_text = 'CR: 1/6';
    elseif dim == 256
        cr_text = 'CR: 1/12';
    else
        cr_text = 'CR: Unknown';
    end

    % 스택형 막대 그래프 그리기
    figure;
    bar(targetPSNR, flopsData, 'stacked');

    % 그래프 설정
    xlabel('Target PSNR (dB)');
    ylabel('FLOPs');
    ylim([0, 70000]);
    grid on;
    legend('Lv4', 'Lv3', 'Lv2', 'Lv1', 'Location','northwest');
    title(sprintf('%s, SNR: %d dB', cr_text, snr));
end

% 함수 호출 예시

'DE > Graph' 카테고리의 다른 글

Random Activate layer  (0) 2024.09.03
TopK Activate layer  (0) 2024.09.03
X: Target PSNR, Y: FLOPs, SNR : [40, 20], CR: [1/6, 1/12]  (0) 2024.09.03
[CBS / TopK / RS] : target PSNR, level select, final FLOPs, avg PSNR  (0) 2024.09.02
X : SNR, Y : Avg PSNR  (0) 2024.09.01
Comments