TensorFlow 1: Heavily based on graph execution with lazy evaluation.
TensorFlow 2: Introduced eager execution, meaning operations are evaluated immediately when defined.
Easier for those coming from a Python background, more suitable for beginners to experts.
TensorFlow Architecture
Main Blocks
Training Block: Supports distributed training strategies, core written in C++, supports CPU, GPU, TPU, and multi-node execution.
Model Definition: Utilizes high-level APIs like Keras (recommended) and estimators (not recommended in newer versions).
Data Handling:
TensorFlow Data API (tf.data) provides flexibility in data access and processing.
Direct conversion of datasets to tensors without additional steps.
Key Features of TensorFlow 2
TensorBoard for analysis and visualization of models.
Model Saving: Serialization for instant model saving and retrieval.
TensorFlow Hub provides access to pre-trained models.
Deployment Options:
TensorFlow.js for web applications.
TensorFlow Lite for mobile and embedded devices.
TensorFlow Serving for cloud deployment.
Model Development Workflow
Data Preparation: Feature engineering and normalization of data.
Model Definition: Use Keras or custom APIs to build models.
Keras APIs provide easy access to pre-built layers.
Training:
Eager execution and autographs for efficiency.
Training strategies with distribution, and TensorBoard for monitoring.
Use callbacks (e.g., for checkpoints, early stopping).
Model Building Approaches
Sequential API: Simple models for beginners, single input/output.
Functional API: Allows multiple inputs/outputs, more control over model architecture.
Custom Layers & Metrics: Define custom layers, metrics, and losses for training.
Subclassing: Flexible, similar to programming from scratch.
TensorFlow 2 Training Methods
model.fit(): Simplified training loop with automatic gradient descent.
Callbacks integration for advanced control over the training process.
Custom training loops with gradient tape for full control over training operations.
Tensor Data Types
Similarities to NumPy, supporting multi-dimensional arrays.
Types: Tensors can be immutable (constants) or mutable (variables).
Rank and Shape: Defines the dimensionality and number of elements in each dimension.
TensorFlow Data API
Flexibility in loading and processing data.
Integration with tf.data for efficient data handling.
Caching options to improve performance during training.
Conclusion
TensorFlow 2.x provides a robust and flexible environment for building, training, and deploying deep learning models, catering to a wide range of users from beginners to advanced practitioners.