Skip to content

Instantly share code, notes, and snippets.

View ryanholbrook's full-sized avatar

Ryan Holbrook ryanholbrook

View GitHub Profile
@danmou
danmou / auto_shape_mixin.py
Created December 5, 2019 10:00
Mixin for `tf.keras.layers.Layer`s and subclasses to automatically define input and output specs the first time the model is called.
from typing import Any, Mapping, Optional, Sequence, TypeVar, Union
import tensorflow as tf
from tensorflow.keras import layers
T = TypeVar('T')
Nested = Union[T, Sequence[T], Mapping[Any, T]]
class AutoShapeMixin:
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@MilesCranmer
MilesCranmer / matrix_box_notation.tex
Last active February 9, 2021 10:49
Draw boxes for matrices in equation
%Make sure to have \usepackage{tikz}
%https://tex.stackexchange.com/a/45815/140440 - for grid
%https://tex.stackexchange.com/a/381175/140440 - for alignment in equation
% This function draws a matrix.
\newcommand{\mat}[2]{% cols, rows
\vcenter{\hbox{ %Vertical alignment
\begin{tikzpicture}[scale=0.3, align=center]
@niklasschmitz
niklasschmitz / jaxpr_graph.py
Last active June 24, 2024 17:53 — forked from mattjj/grad_graph.py
visualizing jaxprs
import jax
from jax import core
from graphviz import Digraph
import itertools
styles = {
'const': dict(style='filled', color='goldenrod1'),
'invar': dict(color='mediumspringgreen', style='filled'),
'outvar': dict(style='filled,dashed', fillcolor='indianred1', color='black'),
@ma7dev
ma7dev / cool_script.sh
Last active May 27, 2025 18:27
takes requirements.txt file without module versions and annotates it with the latest set of module versions that won't result in build/runtime errors.
#!/bin/bash
# TODO: you will need to have conda installed
# create a python environment
conda create -n env_tmp python=3.8.13 -y
# activate environment
conda activate env_tmp
@nmwsharp
nmwsharp / printarr
Last active April 16, 2026 02:50
Pretty print tables summarizing properties of tensor arrays in numpy, pytorch, jax, etc. --- now on pip: `pip install arrgh`
Pretty print tables summarizing properties of tensor arrays in numpy, pytorch, jax, etc.
Now on pip! `pip install arrgh` https://github.com/nmwsharp/arrgh