Skip to content

Instantly share code, notes, and snippets.

import tensorflow as tf
from tensorflow.models.rnn import rnn_cell
from tensorflow.python.framework import dtypes
from tensorflow.python.ops import variable_scope as vs
from tensorflow.python.ops.math_ops import sigmoid, tanh
import numpy as np
def softmax(x):
e_x = np.exp(x - x.max(axis=1)[:, None])
import tensorflow as tf
import numpy as np
import matplotlib.pyplot as plt
from tensorflow.examples.tutorials.mnist import input_data
"""
Utilities
"""
def orthogonal_initializer(scale=1.1):
''' From Lasagne and Keras. Reference: Saxe et al., http://arxiv.org/abs/1312.6120
@nlintz
nlintz / image_to_patches.py
Created March 11, 2016 19:34
Utilities for converting an image into a sequence of non-overlapping patches and back to an image again
import numpy as np
from skimage.util import view_as_blocks
def round_down(num, divisor):
return num - (num % divisor)
def crop_center(img, new_rows, new_cols):
rows, cols, c = img.shape
import tensorflow as tf
import numpy as np
# Parameters
learning_rate = 0.001
decay=.9
training_epochs = 15
batch_size = 100
display_step = 100