Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains hidden or 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 | |
| class ConvolutionalAttentionNLI(object): | |
| def __init__(self, embeddings_shape, target_classes=2, conv_filter_size=3, conv_projection_size=300, attention_output_size=200, comparison_output_size=100, learning_rate=0.05): | |
| self._embeddings_shape = embeddings_shape | |
| self._target_classes = target_classes | |
| self._conv_filter_size = conv_filter_size | |
| self._conv_projection_size = conv_projection_size |
This file contains hidden or 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 numpy as np | |
| import tensorflow as tf | |
| from keras.callbacks import TensorBoard | |
| from keras.layers import Input, Dense | |
| from keras.models import Model | |
| def write_log(callback, names, logs, batch_no): | |
| for name, value in zip(names, logs): | |
| summary = tf.Summary() |
This file contains hidden or 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 numpy import linalg as la | |
| import numpy as np | |
| def nearestPD(A): | |
| """Find the nearest positive-definite matrix to input | |
| A Python/Numpy port of John D'Errico's `nearestSPD` MATLAB code [1], which | |
| credits [2]. |
This file contains hidden or 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
| """Simple example on how to log scalars and images to tensorboard without tensor ops. | |
| License: BSD License 2.0 | |
| """ | |
| __author__ = "Michael Gygli" | |
| import tensorflow as tf | |
| from StringIO import StringIO | |
| import matplotlib.pyplot as plt | |
| import numpy as np |
This file contains hidden or 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 | |
| class TextCNN(object): | |
| """ | |
| A CNN for text classification. | |
| Uses an embedding layer, followed by a convolutional, max-pooling and softmax layer. | |
| """ | |
| def __init__( |
This file contains hidden or 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 numpy as np | |
| from utils import orthogonal, tanh, sigmoid, dtanh, dsigmoid | |
| class LSTM(object): | |
| """Long Short Term Memory Unit | |
| Parameters | |
| ---------- |
This file contains hidden or 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
| # Example for my blog post at: | |
| # https://danijar.com/introduction-to-recurrent-networks-in-tensorflow/ | |
| import functools | |
| import sets | |
| import tensorflow as tf | |
| def lazy_property(function): | |
| attribute = '_' + function.__name__ |
This file contains hidden or 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
| def parent(i): | |
| return i/2 | |
| def left(i): | |
| return 2*i | |
| def right(i): | |
| return (2*i + 1) | |
| class Heap: |
NewerOlder