Back to Resources
Articles

TensorFlow Fundamentals

TensorFlow Fundamentals

Daniel Bourke

TensorFlow Fundamentals

What is TensorFlow?

Open-source ML library for:

  • Data preprocessing
  • Model building
  • Model serving

Key Concepts

Tensors

Multi-dimensional numerical representations:

  • Scalar: 0D (single number)
  • Vector: 1D array
  • Matrix: 2D array
  • Tensor: nD array

Creating Tensors

import tensorflow as tf

# Constants
scalar = tf.constant(7)
vector = tf.constant([10, 10])
matrix = tf.constant([[10, 7], [7, 10]])

# Variables (mutable)
var = tf.Variable([10, 7])

Tensor Operations

  • Addition, subtraction, multiplication
  • Matrix multiplication: tf.matmul()
  • Aggregations: min, max, mean, sum
  • Reshaping: tf.reshape(), tf.transpose()

GPU Acceleration

# Check GPU availability
tf.config.list_physical_devices('GPU')

# TensorFlow automatically uses GPU when available

Best Practices

  • Use tf.function for speed
  • Leverage GPU/TPU when possible
  • Start simple, then optimize
  • Profile and monitor performance

Master tensors to build powerful ML models with TensorFlow.