Skip to content

Instantly share code, notes, and snippets.

View ethancaballero's full-sized avatar

Ethan Caballero ethancaballero

View GitHub Profile
@yohokuno
yohokuno / ptb_word_lm.py
Created December 22, 2016 14:13
TensorFlow implementation of "A Theoretically Grounded Application of Dropout in Recurrent Neural Networks Yarin Gal, Zoubin Ghahramani
# Copyright 2015 The TensorFlow Authors. All Rights Reserved.
#
# 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
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
import argparse
import numpy as np
import tensorflow as tf
from tensorflow.python.framework.errors import FailedPreconditionError
"""Code for data dependent initialization in Weight Normalization paper:
https://arxiv.org/abs/1602.07868
"""

Note: I'm updating this gist as I encounter new reviews, so make sure you're reading the latest revision!

Just as the previous year I collected (and keep doing so) links to various summaries and takeaways from this year's NIPS.

Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
# Inception Score Calculator
#
# A Brock, 2017
#
# This snippet assumes you have two functions defined:
# 1. sample_net, which takes in a batch x num_latents random vector and returns batch samples,
# 2. eval_net, which takes in batch samples and returns a batch x #classes prediction vector.
num_latents = 100
@alrojo
alrojo / rnn_decoder_attention.md
Last active February 19, 2018 06:25
rnn_decoder_attention.md
from tensorflow.python.ops import tensor_array_ops
from tensorflow.python.framework import dtypes
from tensorflow.python.ops import array_ops
from tensorflow.python.ops import control_flow_ops
from tensorflow.python.ops import math_ops
from tensorflow.python.ops import variable_scope as vs
from tensorflow.python.ops import rnn
from tensorflow.python.ops import nn
from tensorflow.python.ops import init_ops
@kastnerkyle
kastnerkyle / tf_multi_rnn.py
Last active March 21, 2018 08:09
Stack LSTMs in TensorFlow
# Stacked LSTMs
# Author: Kyle Kastner
# Based on script from /u/siblbombs
# License: BSD 3-Clause
import tensorflow as tf
from tensorflow.models.rnn import rnn
from tensorflow.models.rnn.rnn_cell import LSTMCell
import numpy as np
import time
import numpy
import theano
import theano.tensor as tt
from theano.gradient import disconnected_grad as stop_grad
x = tt.dscalar('x')
y = x ** 2
gy = tt.grad(y, x)
f = theano.function([x], gy)
@yaroslavvb
yaroslavvb / kfac_nano_eager_test.py
Last active May 31, 2018 22:11
Small example of KFAC in Eager mode
import numpy as np
import tensorflow as tf
import scipy
from tensorflow.contrib.eager.python import tfe
tfe.enable_eager_execution()
# manual numpy example
# X = np.array(([[0., 1], [2, 3]]))
# W0 = X
# W1 = np.array(([[0., 1], [2, 3]]))/10
@mrdrozdov
mrdrozdov / example.py
Last active December 28, 2018 22:10
Logging in Tensorflow
from tf_logger import TFLogger
""" Example of using TFLogger to save train & dev statistics. To visualize
in tensorboard simply do:
tensorboard --logdir /path/to/summaries
This code does depend on Tensorflow, but does not require that your model
is built using Tensorflow. For instance, could build a model in Chainer, then