Skip to content

Instantly share code, notes, and snippets.

@sgraaf
sgraaf / ddp_example.py
Last active November 7, 2024 05:39
PyTorch Distributed Data Parallel (DDP) example
#!/usr/bin/env python
# -*- coding: utf-8 -*-
from argparse import ArgumentParser
import torch
import torch.distributed as dist
from torch.nn.parallel import DistributedDataParallel as DDP
from torch.utils.data import DataLoader, Dataset
from torch.utils.data.distributed import DistributedSampler
from transformers import BertForMaskedLM
"""Automatically build a vanilla or Cudnn RNN."""
import numpy as np
import tensorflow as tf
def gru(inputs,
num_layers,
num_units,
direction='unidirectional',
@asimshankar
asimshankar / README.md
Last active December 25, 2024 22:44
Training TensorFlow models in C++

Training TensorFlow models in C++

Python is the primary language in which TensorFlow models are typically developed and trained. TensorFlow does have bindings for other programming languages. These bindings have the low-level primitives that are required to build a more complete API, however, lack much of the higher-level API richness of the Python bindings, particularly for defining the model structure.

This file demonstrates taking a model (a TensorFlow graph) created by a Python program and running the training loop in C++.