This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use libc::{c_long, size_t}; | |
use std::c_str::CString; | |
pub use base::{PyObject, ToPyType, FromPyType, PyState, PyIterator}; | |
pub use ffi::{PythonCAPI, PyObjectRaw}; | |
pub use base::{PyError, | |
FromTypeConversionError, | |
ToTypeConversionError, | |
NullPyObject}; | |
macro_rules! prim_pytype ( |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from tsne import bh_sne | |
import numpy as np | |
from skimage.transform import resize | |
from matplotlib import pyplot as plt | |
def gray_to_color(img): | |
if len(img.shape) == 2: | |
img = np.dstack((img, img, img)) | |
return img |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import theano | |
from theano import tensor as T | |
import numpy as np | |
from theano.sandbox.cuda.dnn import dnn_conv | |
from theano.sandbox.cuda import host_from_gpu | |
from contexttimer import Timer | |
import theano.compile.mode | |
import theano.printing | |
def speed_test(_func, input_shape): |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# modified from slim | |
@scopes.add_arg_scope | |
def batch_norm(inputs, | |
decay=0.999, | |
scale=False, | |
epsilon=0.001, | |
moving_vars='moving_vars', | |
activation=None, | |
is_training=True, | |
trainable=True, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import tensorflow as tf | |
import numpy as np | |
from tensorflow.python import gen_batchnorm_training_op | |
with tf.device("/gpu:1"): | |
def tf_bn(shape, data_format): | |
""" output tensor for tensorflow implemented batch norm""" | |
data = np.random.randn(*shape)*10 + 5 | |
inp = tf.Variable(data.astype("float32"), tf.float32) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import subprocess | |
import time | |
import os | |
OUTPUT = os.path.expanduser("~/luke_output_network") | |
num_per_file = 1000 | |
try: | |
os.makedirs(OUTPUT) | |
except: | |
print("dir already exists. continuing") |