Skip to content

Instantly share code, notes, and snippets.

lucgiffon

Block or report user

Report or block lucgiffon

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@lucgiffon
lucgiffon / testgpu.py
Created Sep 30, 2019
Verify if tensorflow is capable of using a GPU
View testgpu.py
"""https://stackoverflow.com/a/43703735/4803860"""
import tensorflow as tf
with tf.device('/gpu:0'):
a = tf.constant([1.0, 2.0, 3.0, 4.0, 5.0, 6.0], shape=[2, 3], name='a')
b = tf.constant([1.0, 2.0, 3.0, 4.0, 5.0, 6.0], shape=[3, 2], name='b')
c = tf.matmul(a, b)
with tf.Session() as sess:
print (sess.run(c))
@lucgiffon
lucgiffon / cowsayfortune.sh
Created Jan 22, 2018
Cowsay tell fortune
View cowsayfortune.sh
if [ -x /usr/games/fortune -a -x /usr/games/cowsay ]; then
fortune -a | cowsay -f $(ls /usr/share/cowsay/cows/ | shuf -n1)
fi
@lucgiffon
lucgiffon / np_to_tfrecords.py
Created Dec 20, 2017 — forked from swyoon/np_to_tfrecords.py
From numpy ndarray to tfrecords
View np_to_tfrecords.py
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.
View 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 = "."):
View fastfood.py
'''
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 Jun 29, 2017 — forked from lttlrck/gist:9628955
rename git branch locally and remotely
View gist:f874c43a0c25ff89ac17611c41cefbb0
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 / deprecated.py
Last active Nov 29, 2018
deprecated decorator
View deprecated.py
import warnings
def deprecated(msg=""):
def inner(func):
"""
This is a decorator which can be used to mark functions
as deprecated. It will result in a warning being emitted
when the function is used.
View mplt_layout.py
def mpl_layout(rows_cols, axis=0):
"""
Description:
------------
Prepare matplotlib layout for complexe layouts.
Exemple:
--------
If you have done 6 independant experiences with graphes but you want to show them all in one figure with 2 graphes on each row
and 3 rows of graphes. Moreover, you want to display the graphes by lines, eg: on each row, you want 2 consecutive experiences.
View simple_singleton.py
def singleton(cls):
"""
Simple singleton implementation.
Usage:
@singleton
class A:
pass
@lucgiffon
lucgiffon / singleton.py
Created May 3, 2017 — forked from lambdalisue/singleton.py
Singleton Mixin Class of Python
View singleton.py
#!/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:
You can’t perform that action at this time.