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