Skip to content

Instantly share code, notes, and snippets.

@lucgiffon
lucgiffon / np_to_tfrecords.py
Created December 20, 2017 16:10 — forked from swyoon/np_to_tfrecords.py
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.
@lucgiffon
lucgiffon / mnist.py
Created November 29, 2017 17:38 — forked from akesling/mnist.py
import os
import struct
import numpy as np
"""
Loosely inspired by http://abel.ee.ucla.edu/cvxopt/_downloads/mnist.py
which is GPL licensed.
"""
def read(dataset = "training", path = "."):
'''
Implementation of Fastfood (Le, Sarlos, and Smola, ICML 2013).
Primarily by @esc (Valentin Haenel) and felixmaximilian
from https://github.com/scikit-learn/scikit-learn/pull/3665.
Modified by @dougalsutherland.
FHT implementation was "inspired by" https://github.com/nbarbey/fht.
'''
@lucgiffon
lucgiffon / gist:f874c43a0c25ff89ac17611c41cefbb0
Created June 29, 2017 08:42 — forked from lttlrck/gist:9628955
rename git branch locally and remotely
git branch -m old_branch new_branch # Rename branch locally
git push origin :old_branch # Delete the old branch
git push --set-upstream origin new_branch # Push the new branch, set local branch to track the new remote
@lucgiffon
lucgiffon / singleton.py
Created May 3, 2017 08:16 — forked from lambdalisue/singleton.py
Singleton Mixin Class of Python
#!/usr/bin/env python
# vim: set fileencoding=utf8 :
"""Singleton Mixin"""
class Singleton(object):
"""Singleton Mixin Class
Inherit this class and make the subclass Singleton.
Usage: