Skip to content

Instantly share code, notes, and snippets.

View ShigekiKarita's full-sized avatar
🌴
I may be slow to respond.

Shigeki Karita ShigekiKarita

🌴
I may be slow to respond.
View GitHub Profile
#include <assert.h>
#include <thrust/host_vector.h>
#include <thrust/device_vector.h>
#include <algorithm>
#include <iostream>
#include <limits>
#include <cmath>
#include <utility>
#include <assert.h>
#include <thrust/host_vector.h>
#include <thrust/device_vector.h>
#include <algorithm>
#include <iostream>
#include <limits>
#include <cmath>
#include <utility>
import scipy
from scipy import fftpack
from scipy import signal
from scipy.io import wavfile
import matplotlib.pyplot as plt
def add_eps(x):
x[scipy.where(x == 0)] = scipy.finfo(dtype=x.dtype).eps
return x
"""
PTB RNNLM model
according to tf: https://www.tensorflow.org/tutorials/recurrent#run_the_code
perplexity 120 is nice. 80 is great.
"""
from functools import partial
import torch
import torch.nn as nn
@ShigekiKarita
ShigekiKarita / value.py
Created February 15, 2017 06:29
Python immutable object decorator
from collections import namedtuple
def value(*fields):
def wrapper(class_):
name = class_.__name__
t = namedtuple(name, fields)
return type(name, (class_, t), {})
return wrapper
@ShigekiKarita
ShigekiKarita / .spacemacs
Last active March 12, 2017 03:49
my spacemacs config
;; -*- mode: emacs-lisp -*-
;; This file is loaded by Spacemacs at startup.
;; It must be stored in your home directory.
(defun dotspacemacs/layers ()
"Configuration Layers declaration.
You should not put any user code in this function besides modifying the variable
values."
(setq-default
;; Base distribution to use. This is a layer contained in the directory
@ShigekiKarita
ShigekiKarita / opencl_test.dats
Created December 29, 2016 06:56
ATS2 with OpenCL
#include "share/atspre_define.hats"
#include "share/atspre_staload.hats"
(* README
original :
https://github.com/smistad/OpenCL-Getting-Started
compile with CUDA devices:
patscc -o test ./opencl_test.dats -L/usr/local/cuda/lib64 -lOpenCL
@ShigekiKarita
ShigekiKarita / file0.txt
Last active December 26, 2016 17:38
CUDA8のマルチストリーム/スレッド処理にC++11のfuture/threadを使う ref: http://qiita.com/ShigekiKarita/items/a3891f13f3acc3575c08
$ nvcc ./stream_test.cu -o ./stream_legacy
$ nvvp ./stream_legacy
#include <future>
#include <thread>
#include <map>
#include <vector>
#include <stdio.h>
const int N = 1 << 20;
__global__ void kernel(float *x, int n)
{
@ShigekiKarita
ShigekiKarita / config.mk
Created December 19, 2016 14:43
mxnet config
#-------------------------------------------------------------------------------
# Template configuration for compiling mxnet
#
# If you want to change the configuration, please use the following
# steps. Assume you are on the root directory of mxnet. First copy the this
# file so that any local changes will be ignored by git
#
# $ cp make/config.mk .
#
# Next modify the according entries, and then compile by