BLOG
Python

텐서플로 케라스(Tf.keras)에서 L1, L2 정규화 적용하기


Nov. 1, 2022, 4:26 p.m.



이번 포스트에서는 텐서플로 케라스에서 L1, L2 정규화를 적용하는 방법에 대해서 알아보겠습니다.

이미 텐서플로에서 정규화에 관한 함수들이 tf.keras.regularizers 에 정의 되어 있기 때문에 단지 인스턴스를 가져와서 레이어에 적용만 하면 됩니다.

먼저 L1 정규화를 적용해 보겠습니다.

import tensorflow as tf

l1_reg = tf.keras.regularizers.l1(0.01)

conv = tf.keras.layers.Conv2D(16, kernel_size=(2, 2), activation='relu', input_shape=(128, 128),
        kernel_regularizer=l1_reg)

정말 간단합니다. Conv2D 레이어에 kernel_regularizer로 넣어주어 l1 규제를 적용하였습니다.

L2 정규화도 마찬가지로,

import tensorflow as tf

l2_reg = tf.keras.regularizers.l2(0.01)

conv = tf.keras.layers.Conv2D(16, kernel_size=(2, 2), activation='relu', input_shape=(128, 128),
        kernel_regularizer=l2_reg)

이상입니다.

케라스 인공지능 텐서플로 keras tensorflow


pHqghUme   

555

Jan. 22, 2025, 7:55 a.m.


pHqghUme   

555

Jan. 22, 2025, 7:55 a.m.


pHqghUme   

555

Jan. 22, 2025, 7:55 a.m.


pHqghUme   

-1 OR 2+962-962-1=0+0+0+1 --

Jan. 22, 2025, 7:55 a.m.


pHqghUme   

-1 OR 2+867-867-1=0+0+0+1

Jan. 22, 2025, 7:55 a.m.


pHqghUme   

-1' OR 2+836-836-1=0+0+0+1 --

Jan. 22, 2025, 7:55 a.m.


pHqghUme   

-1' OR 2+808-808-1=0+0+0+1 or '7B03AnmD'='

Jan. 22, 2025, 7:55 a.m.


pHqghUme   

-1" OR 2+718-718-1=0+0+0+1 --

Jan. 22, 2025, 7:55 a.m.


pHqghUme   

555*if(now()=sysdate(),sleep(15),0)

Jan. 22, 2025, 7:55 a.m.


pHqghUme   

5550'XOR(555*if(now()=sysdate(),sleep(15),0))XOR'Z

Jan. 22, 2025, 7:55 a.m.


pHqghUme   

5550"XOR(555*if(now()=sysdate(),sleep(15),0))XOR"Z

Jan. 22, 2025, 7:55 a.m.


pHqghUme   

(select(0)from(select(sleep(15)))v)/*'+(select(0)from(select(sleep(15)))v)+'"+(select(0)from(select(sleep(15)))v)+"*/

Jan. 22, 2025, 7:55 a.m.


pHqghUme   

555-1; waitfor delay '0:0:15' --

Jan. 22, 2025, 7:55 a.m.


pHqghUme   

555-1); waitfor delay '0:0:15' --

Jan. 22, 2025, 7:55 a.m.


pHqghUme   

555-1 waitfor delay '0:0:15' --

Jan. 22, 2025, 7:55 a.m.


pHqghUme   

555BNMJ33Nm'; waitfor delay '0:0:15' --

Jan. 22, 2025, 7:55 a.m.


pHqghUme   

555-1 OR 393=(SELECT 393 FROM PG_SLEEP(15))--

Jan. 22, 2025, 7:55 a.m.


pHqghUme   

555-1) OR 287=(SELECT 287 FROM PG_SLEEP(15))--

Jan. 22, 2025, 7:55 a.m.


pHqghUme   

555-1)) OR 77=(SELECT 77 FROM PG_SLEEP(15))--

Jan. 22, 2025, 7:55 a.m.


pHqghUme   

555Zyrf8Ez7' OR 305=(SELECT 305 FROM PG_SLEEP(15))--

Jan. 22, 2025, 7:55 a.m.


pHqghUme   

555hXBkqL6a') OR 804=(SELECT 804 FROM PG_SLEEP(15))--

Jan. 22, 2025, 7:55 a.m.


pHqghUme   

555IaUI9Sja')) OR 310=(SELECT 310 FROM PG_SLEEP(15))--

Jan. 22, 2025, 7:55 a.m.


pHqghUme   

555*DBMS_PIPE.RECEIVE_MESSAGE(CHR(99)||CHR(99)||CHR(99),15)

Jan. 22, 2025, 7:55 a.m.


pHqghUme   

555'||DBMS_PIPE.RECEIVE_MESSAGE(CHR(98)||CHR(98)||CHR(98),15)||'

Jan. 22, 2025, 7:55 a.m.


pHqghUme   

555

Jan. 22, 2025, 7:55 a.m.


pHqghUme   

555'"

Jan. 22, 2025, 7:55 a.m.


pHqghUme   

555����%2527%2522\'\"

Jan. 22, 2025, 7:55 a.m.


pHqghUme   

@@BKXY5

Jan. 22, 2025, 7:55 a.m.


pHqghUme   

555

Jan. 22, 2025, 7:55 a.m.


pHqghUme   

555

Jan. 22, 2025, 7:55 a.m.


pHqghUme   

555

Jan. 22, 2025, 7:55 a.m.



Search