Skip to content

OpenDPD Examples

This directory contains example scripts demonstrating how to use the OpenDPD Python API.

Files

  • api_usage_example.py - Comprehensive examples of all API functions
  • single_csv_format_example.csv - Example CSV file in the correct format for single CSV datasets

Running the Examples

Prerequisites

Install OpenDPD first:

# From the root OpenDPD directory
pip install -e .

Run the Example Script

python examples/api_usage_example.py

This script demonstrates:

  1. Training a PA model
  2. Training a DPD model
  3. Running the trained DPD model
  4. Using the OpenDPDTrainer class
  5. Loading and inspecting datasets
  6. Creating custom datasets from CSV files
  7. Training with custom dataset paths

Creating Your Own Dataset

Single CSV Format

Create a CSV file with 4 columns: I_in, Q_in, I_out, Q_out

Example:

I_in,Q_in,I_out,Q_out
0.0123,-0.0456,0.0145,-0.0523
-0.0234,0.0567,-0.0267,0.0623
0.0345,-0.0678,0.0389,-0.0745
...

Then use it:

import opendpd
opendpd.train_pa(dataset_path='my_measurements.csv', n_epochs=100)

Split CSV Format

Create a directory with separate CSV files:

MyDataset/
├── spec.json
├── train_input.csv   (columns: I, Q)
├── train_output.csv  (columns: I, Q)
├── val_input.csv
├── val_output.csv
├── test_input.csv
└── test_output.csv

Then use it:

import opendpd
opendpd.train_pa(dataset_path='path/to/MyDataset', n_epochs=100)

Quick Examples

Minimal PA Training

import opendpd
opendpd.train_pa(dataset_name='DPA_200MHz', n_epochs=100)

Minimal DPD Training

import opendpd
opendpd.train_pa(dataset_name='DPA_200MHz', n_epochs=50)
opendpd.train_dpd(dataset_name='DPA_200MHz', n_epochs=50)

Custom Dataset

import opendpd
opendpd.train_pa(dataset_path='my_data.csv', n_epochs=50)

Interactive tutorial

OpenDPD_Tutorial.ipynb is the notebook behind the "Open in Colab" badge of the README: it installs OpenDPD from the main branch, inspects the measured DPA_200MHz data, trains a PA model and a DPD with the per-epoch plots and GIFs of V2.1, compares without DPD and with DPD, exports the predistorted signal, fine-tunes a W16A16 quantized DPD, tries TRes-DeltaGRU with temporal sparsity, and builds a dataset from a CSV. Open it in Colab straight from GitHub: colab.research.google.com/github/lab-emi/OpenDPD/blob/main/examples/OpenDPD_Tutorial.ipynb.

More Information