Skip to content

Instantly share code, notes, and snippets.

@timvieira
timvieira / simple-backprop.py
Last active May 14, 2022 04:32
Simple example of manually performing "automatic" differentiation.
"""
Simple example of manually performing "automatic" differentiation
"""
import numpy as np
from numpy import exp, sin, cos
def f(x, with_grad=False):
# Need to cache intermediates from forward pass (might not use all of them).
a = exp(x)
@TravisDunlop
TravisDunlop / freeze_stable_baselines.py
Last active January 25, 2020 20:34
Freeze a stable-baselines model to a protocol buffer file (i.e. .pb or .bytes)
'''
Freezing a stable-baselines to a frozen protocol buffer file to be served.
https://github.com/hill-a/stable-baselines
Some code taken from this lovely blog series
https://blog.metaflow.fr/tensorflow-how-to-freeze-a-model-and-serve-it-with-a-python-api-d4f3596b3adc
'''
import tensorflow as tf
import os