Skip to content

Instantly share code, notes, and snippets.

@swyoon
swyoon / np_to_tfrecords.py
Last active September 11, 2024 08:28
From numpy ndarray to tfrecords
import numpy as np
import tensorflow as tf
__author__ = "Sangwoong Yoon"
def np_to_tfrecords(X, Y, file_path_prefix, verbose=True):
"""
Converts a Numpy array (or two Numpy arrays) into a tfrecord file.
For supervised learning, feed training inputs to X and training labels to Y.
For unsupervised learning, only feed training inputs to X, and feed None to Y.
@victor-shepardson
victor-shepardson / pytorch-glumpy.md
Last active September 10, 2022 16:09
using pycuda and glumpy to draw pytorch GPU tensors to the screen without copying to host memory
@victor-shepardson
victor-shepardson / pytorch-glumpy.py
Last active October 31, 2024 06:28
using pycuda and glumpy to draw pytorch GPU tensors to the screen without copying to host memory
from contextlib import contextmanager
import numpy as np
import torch
from torch import Tensor, ByteTensor
import torch.nn.functional as F
from torch.autograd import Variable
import pycuda.driver
from pycuda.gl import graphics_map_flags
from glumpy import app, gloo, gl
@janoliver
janoliver / tutorial.md
Created August 10, 2016 08:03
Create scientific presentations with Inkscape, InkSlides and InkTex

In this short article, I show you how to create nice scientific presentations using a combination of Inkscape and LaTex, made possible by two small tools I wrote.

The Tools

  • Inkscape: Our main vector graphics editor to draw the presentation.
  • InkSlides: The python script to convert an Inkscape SVG file to a PDF presentation. Heavily inspired and partly copied from inkscapeslide.
@deeplook
deeplook / pi_digits.py
Created February 13, 2013 20:16
Generate digits of Pi using a spigot algorithm.
"""
Run the algorithm below using CPython, Cython, PyPy and Numba and compare
their performance. (This is implementing a spigot algorithm by A. Sale,
D. Saada, S. Rabinowitz, mentioned on
http://mail.python.org/pipermail/edu-sig/2012-December/010721.html).
"""
def pi_digits(n):
"Generate n digits of Pi."
k, a, b, a1, b1 = 2, 4, 1, 12, 4