Skip to content

Instantly share code, notes, and snippets.

View cemoody's full-sized avatar
👋

Christopher Erick Moody cemoody

👋
View GitHub Profile
@hannes-brt
hannes-brt / ipy_hide_input
Created August 12, 2013 00:20
This is a simple command line tool that adds a small snippet of Javascript to the end of the HTML output of `ipython nbconvert` that hides the input code in the output. This works for both '--to html' and '--to slides' The tool works both when given a file name or by reading from stdin: ```bash ipy_hide_input input_file.slides.html ipython nbcon…
#! /usr/bin/env python
"""
The MIT License (MIT)
Copyright (c) 2013 Hannes Bretschneider
Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
the Software without restriction, including without limitation the rights to
@kastnerkyle
kastnerkyle / conv_deconv_vae.py
Last active April 21, 2023 01:18
Convolutional Variational Autoencoder, modified from Alec Radford at (https://gist.github.com/Newmu/a56d5446416f5ad2bbac)
# Alec Radford, Indico, Kyle Kastner
# License: MIT
"""
Convolutional VAE in a single file.
Bringing in code from IndicoDataSolutions and Alec Radford (NewMu)
Additionally converted to use default conv2d interface instead of explicit cuDNN
"""
import theano
import theano.tensor as T
from theano.compat.python2x import OrderedDict
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# this is a quick implementation of http://arxiv.org/abs/1508.06576
# BUT! This is kind of dirty. Lots of hard coding. 
import numpy as np
import math
from chainer import cuda, Function, FunctionSet, gradient_check, Variable, optimizers
import chainer.functions as Fu
import numpy as np
def slerp(p0, p1, n):
# https://en.wikipedia.org/wiki/Slerp
norm = np.linalg.norm(p0) * np.linalg.norm(p1)
dot = np.sum(p0 * p1 / norm)
theta_0 = np.arccos(dot)
sin_theta_0 = np.sin(theta_0)
interp = []
for t in np.linspace(0.0, 1.0, n):
@eyeseast
eyeseast / python.md
Last active May 6, 2024 17:11
How to set up Python in 2022

I have an updated version of this on my blog here: https://chrisamico.com/blog/2023-01-14/python-setup/.

Python

This is my recommended Python setup, as of Fall 2022. The Python landscape can be a confusing mess of overlapping tools that sometimes don't work well together. This is an effort to standardize our approach and environments.

Tools and helpful links:

  • Python docs: https://docs.python.org/3/
  • Python Standard Library:  - Start here when you're trying to solve a specific problem
@erikbern
erikbern / modal_stable_diffusion_2.py
Last active July 29, 2023 20:10
Run Stable Diffusion 2.0 on Modal
import io
import sys
import modal
stub = modal.Stub(
image=modal.Image.debian_slim()
.apt_install(["git"])
.pip_install(
[