C.W.K.
Stream
Lesson 04 of 07 · published

call() 메서드

~8 min · subclass

Level 0Keras 도제
0 XP0/97 lessons0/20 achievements
0/120 XP to next level120 XP to go0% complete

call(inputs, training=None, mask=None) 의 시그니처 기억. training flag 는 Dropout / BatchNorm 같이 train/eval 다른 layer 가 알아야 함. 직접 호출 시 self.dropout(x, training=training) 같이 전달. mask 는 RNN / attention 의 padding 처리.

call 안에 자유로운 Python — if/for 가능. if training: x = self.dropout(x). dynamic shape 도 OK — tf.shape(x)[0] 같이. 이 자유가 Subclass 의 본질.

백엔드 노트:
⚙️ Backend Note

Code

class <span class="dc">ConditionalLayer</span>(keras.layers.Layer):
    def call(self, inputs, training=False):
        # Use keras.ops for backend-agnostic code!
        x = keras.ops.relu(inputs)
        if training:
            x = keras.ops.nn.dropout(x, rate=0.5)
        return x

External links

Exercise

학습 중에만 Dropout(0.5) 적용하는 Layer subclass 짜. layer(x, training=True) vs layer(x, training=False) 호출 — 출력이 다르게 / input 패턴 그대로 나오는지 확인.

Progress

Progress is local-only — sign in to sync across devices.
이 페이지에서 버그를 발견하셨거나 피드백이 있으세요?문제 신고

댓글 0

🔔 답글 알림 (로그인 필요)
로그인댓글을 남기려면 로그인해 주세요.

아직 댓글이 없어요. 첫 댓글을 남겨보세요.