An open-source machine learning framework developed by Google. Builds and trains deep learning models based on tensor (multidimensional array) computation graphs. Can be deployed to various platforms such as mobile and web with TensorFlow Lite and TensorFlow.js.
TensorFlow is an open-source machine learning framework released by the Google Brain team in 2015. The "Tensor" in its name means a multidimensional array, and "Flow" means a data flow graph. Starting with TensorFlow 2.x, Keras is integrated as the default high-level API, enabling intuitive model definition and training. The current version, 2.18 (as of 2025), is the latest stable version and supports CUDA 12.3 and cuDNN 8.9.7.
TensorFlow's core strength is production deployment. You can serve models as REST/gRPC APIs with TensorFlow Serving, deploy them to mobile/embedded devices with TensorFlow Lite, and run them in web browsers with TensorFlow.js. In addition, its optimized integration with TPU (Tensor Processing Unit) hardware delivers excellent performance for large-scale training on Google Cloud.
TensorFlow supports two modes: Eager Execution and Graph Execution. In TF 2.x, Eager is the default, but you can compile performance-critical parts into a graph with the @tf.function decorator. This hybrid approach lets you get both development convenience and production performance.
The TensorFlow ecosystem includes a variety of tools such as TensorBoard (visualization), TFX (ML pipelines), TF Hub (pretrained models), and TF Extended (production ML). In particular, TensorBoard provides loss/accuracy graphs of the training process, model structure, embedding visualization, and more, making it an essential tool for model debugging and analysis.
💻 Code Example
An example of building and training an image classification model using the Keras API.
import tensorflow as tf
from tensorflow import keras
from tensorflow.keras import layers
import numpy as np
# GPU 메모리 동적 할당 설정
gpus = tf.config.experimental.list_physical_devices('GPU')
if gpus:
for gpu in gpus:
tf.config.experimental.set_memory_growth(gpu, True)
# 샘플 데이터셋 로드 (CIFAR-10)
(x_train, y_train), (x_test, y_test) = keras.datasets.cifar10.load_data()
x_train, x_test = x_train / 255.0, x_test / 255.0
# CNN 모델 정의
model = keras.Sequential([
layers.Conv2D(32, (3, 3), activation='relu', input_shape=(32, 32, 3)),
layers.MaxPooling2D((2, 2)),
layers.Conv2D(64, (3, 3), activation='relu'),
layers.MaxPooling2D((2, 2)),
layers.Conv2D(64, (3, 3), activation='relu'),
layers.Flatten(),
layers.Dense(64, activation='relu'),
layers.Dropout(0.5),
layers.Dense(10, activation='softmax')
])
# 모델 컴파일
model.compile(
optimizer='adam',
loss='sparse_categorical_crossentropy',
metrics=['accuracy']
)
# 콜백 설정
callbacks = [
keras.callbacks.EarlyStopping(patience=3, restore_best_weights=True),
keras.callbacks.TensorBoard(log_dir='./logs'),
keras.callbacks.ModelCheckpoint('best_model.keras', save_best_only=True)
]
# 모델 학습
history = model.fit(
x_train, y_train,
epochs=20,
batch_size=64,
validation_split=0.2,
callbacks=callbacks
)
# 모델 평가
test_loss, test_acc = model.evaluate(x_test, y_test, verbose=2)
print(f'테스트 정확도: {test_acc:.4f}')
# 모델 저장 및 로드
model.save('cifar10_model.keras')
loaded_model = keras.models.load_model('cifar10_model.keras')
# TFLite 변환 (모바일 배포용)
converter = tf.lite.TFLiteConverter.from_keras_model(model)
tflite_model = converter.convert()
with open('model.tflite', 'wb') as f:
f.write(tflite_model)
📊 Performance & Cost
System requirements and a version-by-version comparison for TensorFlow 2.18 (as of January 2025).
GPU Requirements
Requirement
TensorFlow 2.18
TensorFlow 2.15
CUDA Version
12.3
12.2
cuDNN Version
8.9.7
8.9.4
Python Version
3.9 - 3.12
3.9 - 3.11
Minimum GPU
Pascal (compute 6.0)
Pascal (compute 6.0)
Recommended VRAM
8GB or more
8GB or more
Framework Comparison
Characteristics
TensorFlow
PyTorch
High-Level API
Keras (built-in)
PyTorch Lightning
Mobile Deployment
TFLite (excellent)
PyTorch Mobile
Production Serving
TF Serving
TorchServe
TPU Support
Native support
Supported via XLA
Ease of Debugging
TF 2.x Eager Mode
Eager by default
Research vs. Production
Production strength
Research strength
TensorFlow is free to use as open source. Using Google Cloud TPUs incurs separate costs
🗣️ Say It Like This in Practice
"I migrated to TensorFlow 2.x and using the Keras Sequential API made things much simpler"
→ Expresses that in TensorFlow 2.x, Keras is integrated as the default API, making model definition simpler
"I converted it to TFLite and deployed it to Android, and applying quantization cut the model size to a quarter"
→ Explains TensorFlow Lite mobile deployment and quantization optimization
"If you run training with TensorBoard on, you can watch the loss graph in real time, which is nice"
→ Using TensorBoard as a visualization tool
⚠️ Common Mistakes & Cautions
GPU memory full-allocation issue
By default, TensorFlow allocates all of the GPU memory. You should set set_memory_growth(True) so that it uses only as much as needed.
Mixing TF 1.x and 2.x code
TF 1.x-style code such as tf.compat.v1.Session() is inefficient in 2.x. Use tf.function and Eager Execution.
CUDA/cuDNN version mismatch
The CUDA/cuDNN versions required differ by TensorFlow version. Be sure to check the compatibility table in the official documentation.
Confusion over model save formats
There are the .h5 (legacy) and .keras (new) formats. In TF 2.x, the .keras format is recommended.