Skip to content

Instantly share code, notes, and snippets.

@nlgranger
nlgranger / Dockerfile
Created February 9, 2017 14:49
Minimal Nvidia docker with latest torch version
FROM nvidia/cuda:8.0-cudnn5-devel
RUN apt-get update
RUN apt-get upgrade -y
RUN apt-get install -y --no-install-recommends openssl ca-certificates \
git-core cmake curl wget unzip gfortran libreadline-dev ncurses-dev \
libgoogle-glog-dev libboost-dev libboost-thread-dev libopenblas-dev
# Core Torch packages
RUN git clone https://github.com/torch/luajit-rocks.git
FROM nvidia/cuda:8.0-cudnn5-devel
WORKDIR /root
RUN apt-get update
RUN apt-get upgrade -y
RUN apt-get install -y --no-install-recommends openssl ca-certificates \
git-core cmake curl wget unzip gfortran libreadline-dev ncurses-dev \
libgoogle-glog-dev libboost-dev libboost-thread-dev libopenblas-dev
@nlgranger
nlgranger / command_and_output
Last active January 24, 2018 09:57
standalone CTC in Theano
$ nosetests .
Using cuDNN version 7005 on context None
Preallocating 9494/11170 Mb (0.850000) on cuda1
Mapped name None to device cuda1: GeForce GTX 1080 Ti (0000:03:00.0)
EEE
======================================================================
ERROR: test_forward_backward (test_ctc.TestCTC)
--------------------------------------------------
@nlgranger
nlgranger / wideresnet.py
Last active February 6, 2018 11:30
Wide ResNet in Lasagne/Theano
from lasagne.layers import BatchNormLayer, NonlinearityLayer, Conv2DLayer, \
DropoutLayer, ElemwiseSumLayer, GlobalPoolLayer
from lasagne.nonlinearities import rectify
from lasagne.init import HeNormal
def wide_resnet(l_in, d, k, dropout=0.):
"""Build a Wide-Resnet WRN-d-k [Zagoruyko2016]_
Parameters
@nlgranger
nlgranger / generic_linkcode_resolve_for_sphinx.py
Last active May 18, 2024 06:27
A generic implementation of linkcode_resolve for the 'sphinx.ext.viewcode' extension of sphinx
# the sphinx extension 'sphinx.ext.viewcode' links documentation to an online
# code repository but requires to bind the code to the url through a user
# specific `linkcode_resolve` function. This implementation should be fairly
# generic and easily adaptable.
#
# License: Public Domain, CC0 1.0 Universal (CC0 1.0)
import sys
import os
import subprocess
@nlgranger
nlgranger / demo.py
Created February 27, 2018 11:12
tensorflow training script that does not generate graph.pbtxt
import numpy as np
import tensorflow as tf
from procnet.utils import sensible_dir
from experiments.SpatialTransformerNetwork.model import spatial_transformer
from experiments.SpatialTransformerNetwork import dataset
def build_model_layers(inputs, nclasses, is_training):
initializer = tf.contrib.layers.xavier_initializer()
# Implementation of Matching Networks for Tensorflow.
# O. Vinyals, C. Blundell, T. Lillicrap, D. Wierstra, and others,
# “Matching networks for one shot learning,” in Advances in Neural Information
# Processing Systems, 2016, pp. 3630–3638.
# Copyright 2018 Nicolas Granger <[email protected]>
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
@nlgranger
nlgranger / sort_pdist.py
Created July 27, 2018 15:49
sort pairwise distance matrix
# like https://gmarti.gitlab.io/ml/2017/09/07/how-to-sort-distance-matrix.html
# but using just 4 lines of code thanks to 'optimal_ordering' argument
# added to scipy.cluster.hierarchy.linkage
import matplotlib.pyplot as plt
import numpy as np
from scipy.cluster.hierarchy import linkage
# distance matrix
m = np.zeros((500, 500))
@nlgranger
nlgranger / decode.c
Created January 12, 2019 19:59
ffmpeg demo using modern decoding API
#include <stdlib.h>
#include <stdio.h>
#include <errno.h>
#include <libavutil/avutil.h>
#include <libavcodec/avcodec.h>
#include <libavformat/avformat.h>
char err_str[1024];
@nlgranger
nlgranger / PKGBUILD
Created March 3, 2019 19:43
PKGBUILD for libnvidia-container
# Maintainer: Nicolas Granger <[email protected]>
pkgname=libnvidia-container
pkgver=1.0.0
pkgrel=1
pkgdesc="NVIDIA container runtime library"
arch=('x86_64')
url="https://nvidia.github.io/libnvidia-container/"
license=('BSD')
depends=()
makedepends=('bmake' 'rpcsvc-proto')