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

PyTorch Backend

~8 min · backend

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

PyTorch backend 는 *연구·prototype* 의 home. eager-by-default, autograd 가 깔끔, 학계 / Hugging Face / 신규 LLM 다 PyTorch 우선. Keras 3 + PyTorch 면 fit/compile 의 인프라를 *유지하면서* 필요할 땐 raw torch.autograd 도 fall-back.

주의: KERAS_BACKEND=torch 면 model 이 torch tensor 를 받고 내놓아. NumPy / TF tensor 던지면 type error. cross-backend 코드 짜려면 keras.ops 통해서.

백엔드 노트:
⚙️ Backend Note

Code

os.environ["KERAS_BACKEND"] = "torch"
import keras
from keras import layers

model = keras.Sequential([
    layers.Dense(128, activation="relu"),
    layers.Dense(10, activation="softmax"),
])

# Keras model IS a torch.nn.Module
print(isinstance(model, torch.nn.Module))  # True

External links

Exercise

MNIST 스크립트를 KERAS_BACKEND=torch 로 바꿔. 같은 fit/compile 경로가 그대로 도는지 확인. 그다음 batch 에 print(type(x)) 박아 봐 — torch.Tensor 보일 거야.

Progress

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

댓글 0

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

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