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

Backend 마다 바뀌는 것

~8 min · backend

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

portable 과 leaky 의 경계선

backend 를 바꿔도 살아남는 게 뭐고 안 살아남는 게 뭔지 정확히 아는 게, 추상화를 믿는 것과 추상화에 뒤통수 맞는 것의 차이야. 다행히 Keras 코드로 짠 건 거의 다 불변이고, 차이는 backend-native 객체를 직접 만지는 *seam* 에서만 드러나.

그대로인 것

  • model 정의 — Sequential·Functional·Subclassing 다 동일
  • train loop — model.compile() + model.fit()
  • callback — EarlyStopping·ModelCheckpoint 등
  • .keras 저장 포맷
  • 모든 keras.ops 연산

바뀌는 것 (어디서 leak 하나)

아래 차이는 Keras 너머 engine 으로 손 뻗을 때만 물어 — raw tensor 꺼내거나, device 에 직접 올리거나, backend-native 라이브러리 섞을 때:

측면TensorFlowPyTorchJAX
tensor 타입tf.Tensortorch.Tensorjax.Array
device 관리tf.device.to(device)jax.devices()
layer 정체Keras layertorch.nn.ModuleKeras layer
JIT 컴파일tf.functiontorch.compilejax.jit (default)

실전 룰: Keras + keras.ops 안에만 있으면 이 칸 쇼핑은 의미 없어 — model 이 진짜로 portable. native 코드로 건너가는 순간 그 경계를 명확히 표시해 — backend 교체가 너를 깨뜨릴 수 있는 유일한 자리니까.

External links

Exercise

같은 model + train loop 을 세 backend 다 짜. backend-specific 한 거 한 곳이라도 있는지 메모. 그 리스트가 비어있게 만드는 게 목표.

Progress

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

댓글 0

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

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