Skip to content

Instantly share code, notes, and snippets.

View floringogianu's full-sized avatar
🐳
Chasing Moby-Dick

Florin Gogianu floringogianu

🐳
Chasing Moby-Dick
View GitHub Profile
@floringogianu
floringogianu / null.py
Created December 8, 2017 15:53 — forked from fish830617/null.py
Calculate the null space of a matrix by QR factorization.
# null.py
import numpy as np
from scipy.linalg import qr
def qr_null(A, tol=None):
Q, R, P = qr(A.T, mode='full', pivoting=True)
tol = np.max(A) * np.finfo(R.dtype).eps if tol is None else tol
rnk = min(A.shape) - np.abs(np.diag(R))[::-1].searchsorted(tol)
return Q[:, rnk:].conj()
@floringogianu
floringogianu / gist:38f54d01ff46d11aef0e48377d213c4d
Created November 27, 2017 15:28 — forked from tomerfiliba/gist:3698403
get the indexes of the top n elements in a numpy 2d-array
import numpy as np
import bottleneck as bn
def top_n_indexes(arr, n):
idx = bn.argpartsort(arr, arr.size-n, axis=None)[-n:]
width = arr.shape[1]
return [divmod(i, width) for i in idx]
np.random.seed(47)
@floringogianu
floringogianu / conda-env-autodetect.plugin.zsh
Last active July 18, 2018 03:18
zsh plugin for autodetecting conda environments based on a .venv file in your project
# conda-env-autodetect.plugin.zsh
# Copy this file to ~/.oh-my-zsh/plugins/conda-env-autodetect/
# And make sure you have a .venv file with your env's name in your
# preject's root folder.
_conda_env_auto_activate() {
if [ -f ".venv" ]; then
# check conda is active

#Create bitbucket branch

##Create local branch

$ git checkout -b sync
Switched to a new branch 'sync'
$ git branch
  master
* sync
@floringogianu
floringogianu / resize_benchmark.py
Created May 1, 2017 20:58
Simple benchmark of image resize methods.
import time
import numpy as np
from skimage.transform import resize
from PIL import Image
def pil_resize(x, target, method=Image.NEAREST):
img = Image.fromarray(x)
return np.array(img.resize(target, resample=method))
@floringogianu
floringogianu / pytorch_setup_log.log
Created February 15, 2017 03:13
Pytorch setup log
running install
running build_deps
-- The C compiler identification is AppleClang 8.0.0.8000042
-- The CXX compiler identification is AppleClang 8.0.0.8000042
-- Check for working C compiler: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/cc
-- Check for working C compiler: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/cc -- works
-- Detecting C compiler ABI info
-- Checking if C linker supports --verbose
-- Checking if C linker supports --verbose - no
-- Detecting C compiler ABI info - done
@floringogianu
floringogianu / color.string
Created November 29, 2016 15:25
Colored strings in Lua
-- credit to Jesse Paroz (@jparoz)
local FG = {
black = 30,
red = 31,
green = 32,
yellow = 33,
blue = 34,
magenta = 35,
cyan = 36,
white = 37,
# This should work with xitari (the c++ Arcade Learning Environment fork) too.
# Define a type for the c struct pointer
type DoomGame end
# Load the shared object. This needs to expose c functions (see "extern C")
newGame = ccall( (:vizdoom_new, "libvizdoom"), Ptr{DoomGame}, ())
# Load a configuration file.
hasLoaded = ccall( (:vizdoom_loadConfig, "libvizdoom"), Bool, (Ptr{DoomGame},Cstring), newGame, "../../examples/config/basic.cfg")
require 'torch'
require 'cutorch'
require 'nn'
require 'cunn'
require 'cudnn'
local N = 32
local cin = 64
local cout = 64
local height = 256
@floringogianu
floringogianu / fc_benchmark.lua
Created April 20, 2016 11:09 — forked from jcjohnson/fc_benchmark.lua
Simple torch benchmarking tool for fully-connected networks
require 'nn'
require 'cutorch'
require 'cunn'
--[[
-- A simple benchmark comparing fully-connected net times on CPU and GPU.
--
-- Note that we don't count time it takes to transfer data to the GPU.
--]]