Skip to content

Latest commit

 

History

3 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 

Repository files navigation

TensorFlow Tutorial - Interactive Jupyter Notebooks

Welcome to the TensorFlow tutorial series! These interactive notebooks are designed to help colleagues learn the fundamentals of TensorFlow and deep learning through hands-on examples.

� Quick Start - Click to Launch!

Run these notebooks directly in your browser - no setup required!

Chapter 1: Introduction to TensorFlow and Neural Networks

Open In Colab

Learn the basics of TensorFlow and neural networks by building a simple model that learns linear relationships.

Topics covered:

  • TensorFlow and Keras basics
  • Building simple neural networks
  • Training models with gradient descent
  • Making predictions
  • Visualizing model learning

Duration: ~30-45 minutes


Chapter 2: Image Classification with CNNs

Open In Colab

Build a Convolutional Neural Network (CNN) to classify images of horses and humans.

Topics covered:

  • Convolutional Neural Networks (CNNs)
  • Image preprocessing and data generators
  • Multi-layer CNN architectures
  • Training on image datasets
  • Model evaluation and visualization
  • Understanding overfitting

Duration: ~1-1.5 hours


� How to Use These Notebooks

Option 1: Google Colab (Recommended - Zero Setup!)

Just click the badges above! The notebooks will open directly in Google Colab where you can:

  • Run all code interactively in your browser
  • Get free GPU access for faster training
  • No installation or setup required
  • All data downloads automatically
  • Changes are saved to your Google Drive

Option 2: GitHub Codespaces (Cloud Development Environment)

  1. Click the Code button at the top of this repository
  2. Select CodespacesCreate codespace on main
  3. Wait for the environment to load (~1-2 minutes)
  4. Install dependencies: pip install -r requirements.txt
  5. Run: jupyter notebook
  6. Open the notebooks and start coding!

Option 3: Run Locally with Jupyter

If you prefer to run on your own machine:

# Clone this repository
git clone https://github.com/gsstephenson/tensorflow_tutorial.git
cd tensorflow_tutorial

# Create a virtual environment (optional but recommended)
python -m venv tf_env
source tf_env/bin/activate  # On Windows: tf_env\Scripts\activate

# Install required packages
pip install -r requirements.txt

# Launch Jupyter Notebook
jupyter notebook

Then navigate to the chapter folder and open the notebook.


📦 Requirements

Python Packages

  • tensorflow >= 2.x
  • numpy
  • matplotlib
  • jupyter or jupyterlab

Hardware

  • Minimum: Any modern CPU (training will be slower)
  • Recommended: GPU-enabled machine or cloud service (Google Colab)

📖 How to Use These Notebooks

  1. Read the markdown cells carefully - They explain concepts and provide context
  2. Run code cells sequentially - Use Shift+Enter to execute each cell
  3. Experiment! - Modify parameters and see what happens
  4. Complete the exercises - Each notebook has hands-on challenges
  5. Don't skip visualizations - They help build intuition

Tips for Success:

  • ✅ Don't rush - take time to understand each concept
  • ✅ Run all code cells, even if you think you understand
  • ✅ Try the exercises before looking at solutions
  • ✅ Experiment with different parameters
  • ✅ Ask questions when you're stuck

🎯 Learning Objectives

By the end of this tutorial series, colleagues will be able to:

  • Understand the fundamentals of neural networks
  • Build and train models using TensorFlow/Keras
  • Work with different types of data (numerical and images)
  • Understand and implement CNNs
  • Evaluate model performance
  • Debug common issues in deep learning
  • Interpret training metrics and visualizations

📁 Repository Structure

tensorflow_tutorial/
├── README.md                          # This file
├── chapter_1/
│   ├── Chapter_1_Introduction_to_TensorFlow.ipynb
│   └── tf-sgd-test.py                # Original script (for reference)
├── chapter_2/
│   ├── Chapter_2_Image_Classification_CNN.ipynb
│   └── h-or-h/
│       ├── h-or-h-cnn.py             # Original script (for reference)
│       ├── tf-download-ch2.py         # Original script (for reference)
│       └── horse-or-human/            # Dataset (auto-downloaded by notebook)
└── requirements.txt                   # Python dependencies (optional)

🐛 Troubleshooting

Common Issues:

1. TensorFlow installation fails

# Try installing with specific version
pip install tensorflow==2.14.0

2. Out of memory errors

  • Reduce batch size in the data generator
  • Use smaller image sizes
  • Close other applications

3. Slow training

  • Use Google Colab with GPU enabled
  • Reduce number of epochs for testing
  • Use smaller datasets initially

4. Images not displaying

# Add this at the top of the notebook
%matplotlib inline

🔗 Additional Resources

Official Documentation

Learning Resources

Community


🤝 Contributing

Colleagues and collaborators are welcome to contribute improvements!

  • Report issues or bugs
  • Suggest new examples or exercises
  • Improve documentation
  • Add new chapters

📝 License

This tutorial is provided for educational purposes. Feel free to use and modify for your courses.


👨‍🏫 For Instructors

Suggested Teaching Approach:

  1. Pre-class: Have colleagues set up their environment
  2. In-class: Walk through notebooks together, pausing for discussions
  3. Lab time: Colleagues work on exercises with instructor support
  4. Homework: Additional experimentation and parameter tuning
  5. Assessment: Mini-project applying learned concepts

Customization Ideas:

  • Add your own datasets relevant to your field
  • Create additional exercises specific to your curriculum
  • Extend with more advanced topics (transfer learning, RNNs, etc.)
  • Add quizzes or checkpoints within notebooks

🆘 Getting Help

If you encounter issues:

  1. Check the troubleshooting section above
  2. Review the error message carefully
  3. Search for the error online (Stack Overflow is helpful)
  4. Ask your instructor or teaching assistant
  5. Post in the TensorFlow forum with a clear description

🎓 Next Steps After Completion

Ready for more? Try these:

  1. Transfer Learning: Use pre-trained models (VGG16, ResNet)
  2. Multi-class Classification: Classify more than 2 categories
  3. Object Detection: Locate and classify objects in images
  4. Natural Language Processing: Apply deep learning to text
  5. Reinforcement Learning: Train agents to play games

Happy Learning! 🚀

Last Updated: November 2025

About

TensorFlow tutorial with interactive Jupyter notebooks for colleagues. These activities were taken from the O'Reilly textbook: AI and Machine Learning for Coders by Lawrence Moroney

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages