Skip to main content
Brave Programmer Logo

BraveProgrammer

BraveProgrammer

HomeProjectsBlogsCoursesLessonsAbout

Site footer

BraveProgrammer

Free coding courses, practical tutorials, and real projects from BraveProgrammer. Learn web development with React, Next.js, and TypeScript.

Navigation

  • Home
  • Projects
  • Blogs
  • Courses

Resources

  • About
  • Lessons
  • Teach on BraveProgrammer

© 2026 BraveProgrammer. All rights reserved.

Deep Learning Founda | Master Data Science with Python lesso | BraveProgrammer
  1. Courses
  2. /
  3. Master Data Science with Python

Lesson 56 of 60

·python

Deep Learning Foundations – TensorFlow Basics

25 minutes

Course progress93%

TensorFlow Basics

TensorFlow is an open‑source library for numerical computation and large‑scale machine learning. Keras, now integrated as tf.keras, provides a high‑level API.

Installing TensorFlow

pip install tensorflow

Hello World: a simple dense network

import tensorflow as tf
from tensorflow  keras
 tensorflow.keras  layers


model = keras.Sequential([
    layers.Dense(, activation=, input_shape=(,)),
    layers.Dense(, activation=)
])

model.(optimizer=, loss=, metrics=[])
(model.summary())
import
from
import
# Define a simple sequential model
64
'relu'
10
1
'linear'
compile
'adam'
'mse'
'mae'
print

Training workflow

# Dummy data
import numpy as np
X = np.random.rand(1000, 10)
y = X @ np.random.rand(10,1) + np.random.randn(1000,1)*0.1

history = model.fit(X, y, epochs=30, batch_size=32, validation_split=0.2)

Visualizing training curves

import matplotlib.pyplot as plt
plt.plot(history.history['loss'], label='train loss')
plt.plot(history.history['val_loss'], label='val loss')
plt.legend()
plt.title('Training & Validation Loss')
plt.show()

Saving and loading models

model.save('my_model.h5')
# later
loaded = keras.models.load_model('my_model.h5')

GPU acceleration (optional)

  • Install tensorflow-gpu or use the default TensorFlow (GPU support is built‑in for recent builds).
  • Verify with tf.config.list_physical_devices('GPU').

Key concepts

  • Tensors: N‑dimensional arrays (like NumPy, but GPU‑compatible).
  • Eager execution (default) vs. graph execution.
  • Layers: building blocks (Dense, Conv2D, LSTM, …).
  • Model subclassing for custom architectures.

Info

Use the functional API (keras.Model) when you need multiple inputs or outputs.
Make it stickPractice what you've learned1 quiz · 4 practical tests · Optional activities from Master Data Science with PythonBrowse activities
Previous lessonEnsemble Methods – Gradient Boosting (XGBoost)Continue to lesson 57Neural Networks Fundamentals – Architecture & TrainingBack to Master Data Science with Python curriculum