Skip to content

Instantly share code, notes, and snippets.

View thiagopbueno's full-sized avatar

Thiago P. Bueno thiagopbueno

View GitHub Profile
@thiagopbueno
thiagopbueno / tf_function.md
Last active September 17, 2020 00:13
TensorFlow Autograph

Tips

  • Pass numeric arguments as tf.Tensor objects (to avoid building new graphs and unnecessary retracing)
  • Beware of hidden side effects
  • Pay attention to undefined values (special care with if/else statements and assymetric returns)
  • Pay attention to lexical/dynamical scopes
  • Do not create object attributes inside autographed functions (mutations lead to undefs)
  • Avoid using Python lists; prefer tf.TensorArray
  • To accumulate results from a dynamically unrolled loop, use tf.TensorArray
  • Use tf.TensorSpec(shape=..., dtype=...) in input_signature to avoid proliferation of graphs
@thiagopbueno
thiagopbueno / tf_snippets.md
Last active November 27, 2019 15:54
TensorFlow snippets
@thiagopbueno
thiagopbueno / ssh-key.md
Last active August 28, 2019 14:47
SSH key in GitHub
@thiagopbueno
thiagopbueno / matplotlib-latex.py
Last active July 11, 2019 14:45
Matplotlib for LaTex pdf
import matplotlib
# http://phyletica.org/matplotlib-fonts/
matplotlib.rcParams['pdf.fonttype'] = 42
matplotlib.rcParams['ps.fonttype'] = 42
matplotlib.rcParams['text.usetex'] = True
# https://nerdjusttyped.blogspot.com/2010/07/type-1-fonts-and-matplotlib-figures.html
matplotlib.rcParams['ps.useafm'] = True
matplotlib.rcParams['pdf.use14corefonts'] = True
@thiagopbueno
thiagopbueno / setup-template.py
Last active May 24, 2023 04:58
Setuptools template for open-source Python projects.
import os
from setuptools import setup, find_packages
def read(filename):
filepath = os.path.join(os.path.dirname(__file__), filename)
file = open(filepath, 'r')
return file.read()
@thiagopbueno
thiagopbueno / sphinx-commands.md
Last active November 11, 2020 21:50
Sphinx commands for generating documentation for python projects.

Quickstart

Installation

Run in the project virtualenv:

$ pip3 install Sphinx

Run in docs/ folder.

@thiagopbueno
thiagopbueno / CUDD-ADD
Last active May 15, 2019 21:30
Using CUDD library to manipulate algebraic decision diagrams (ADDs)
CC=g++
CCFLAGS=-Wall -Wextra -ansi -pedantic -std=c++11
CUDD=/usr/local/CUDD/cudd-3.0.0
INCLUDE=-I$(CUDD)/cudd -I$(CUDD)/cplusplus
LIBS=$(CUDD)/cudd/.libs/libcudd.a
cudd: main.o
$(CC) -o $@ $^ $(LIBS)