Before constructing neural networks, you need a suitable development environment. Deep learning relies heavily on specific software libraries, and managing these efficiently is important for a smooth workflow. This section guides you through setting up the necessary tools.
Python is the dominant language for deep learning, primarily due to its extensive ecosystem of scientific computing and machine learning libraries. We assume you have a working Python installation (version 3.8 or newer is recommended). If not, download it from the official Python website or use a distribution like Anaconda.
Deep learning projects often depend on specific versions of libraries. Installing everything globally can lead to conflicts between projects. Virtual environments isolate project dependencies, ensuring that libraries installed for one project don't interfere with others.
Using venv
(Built-in)
Python's built-in venv
module is a lightweight option:
python -m venv venv_dl # Replace venv_dl with your preferred name
source venv_dl/bin/activate
.\venv_dl\Scripts\activate
(venv_dl)
).Using Conda (Part of Anaconda/Miniconda)
Conda is a popular package and environment manager, especially useful for handling complex scientific packages:
conda create --name env_dl python=3.9 # Specify name and Python version
conda activate env_dl
All subsequent library installations should happen after activating your chosen virtual environment.
You'll primarily use a high-level deep learning framework to build and train models without implementing every detail from scratch. The two most popular choices are PyTorch and TensorFlow (often used via its Keras API). This course will primarily use PyTorch examples, but the concepts apply to both.
Installing PyTorch
Visit the official PyTorch website for the most up-to-date installation command tailored to your operating system (Linux, macOS, Windows) and compute platform (CPU, GPU/CUDA version).
A typical pip installation command for a CPU-only version looks like this:
pip install torch torchvision torchaudio
For GPU support (using NVIDIA CUDA), the command will differ based on your CUDA version. The PyTorch website provides a configurator to generate the correct command. For example, for CUDA 11.8:
pip install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cu118
Installing TensorFlow with Keras
TensorFlow also provides straightforward installation via pip:
pip install tensorflow
This command typically installs the CPU version. GPU support might require additional steps for CUDA and cuDNN installation, specific to your system. Consult the TensorFlow installation guide for details.
Beyond the core framework, several other Python libraries are standard tools in the data science and machine learning workflow:
pip install numpy
pip install pandas
pip install matplotlib seaborn
pip install scikit-learn
You can install multiple libraries at once:
pip install numpy pandas matplotlib seaborn scikit-learn
How you write and execute your code is a matter of preference, but two common approaches are:
pip install jupyterlab
Then launch it from your activated environment by running jupyter lab
in the terminal.You can set up your environment on your local machine (laptop or desktop). However, training large deep learning models can be computationally intensive and benefit significantly from Graphics Processing Units (GPUs).
After installing the core components, it's good practice to verify that they are accessible within your activated environment. Open a Python interpreter or a Jupyter Notebook and try importing them:
import platform
import torch
import tensorflow as tf # Optional, if installed
import numpy as np
import pandas as pd
import sklearn
import matplotlib
import seaborn
print(f"Python version: {platform.python_version()}")
print(f"PyTorch version: {torch.__version__}")
# Check for GPU availability in PyTorch
if torch.cuda.is_available():
print(f"PyTorch CUDA available: True, version: {torch.version.cuda}")
print(f"Device name: {torch.cuda.get_device_name(0)}")
else:
print("PyTorch CUDA available: False")
# Optional TensorFlow check
# print(f"TensorFlow version: {tf.__version__}")
# gpu_devices = tf.config.list_physical_devices('GPU')
# print(f"TensorFlow GPU devices: {gpu_devices}")
print(f"NumPy version: {np.__version__}")
print(f"Pandas version: {pd.__version__}")
print(f"Scikit-learn version: {sklearn.__version__}")
print(f"Matplotlib version: {matplotlib.__version__}")
print(f"Seaborn version: {seaborn.__version__}")
If these commands execute without ImportError
messages, your basic environment is ready. You now have the tools needed to start defining, training, and evaluating deep learning models.
© 2025 ApX Machine Learning