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
# Decomposable attention model for NLI | |
# https://arxiv.org/pdf/1606.01933v1.pdf | |
dnli_graph = tf.Graph() | |
with dnli_graph.as_default(): | |
embedding_matrix = tf.Variable(tf.zeros([DICTIONARY_SIZE, EMBEDDING_SIZE]), name='word_embeddings', trainable=False) | |
embedding_placeholder = tf.placeholder(tf.float32, [DICTIONARY_SIZE, EMBEDDING_SIZE]) | |
embedding_init_op = embedding_matrix.assign(embedding_placeholder) | |
X_Q1 = tf.placeholder(tf.int32, [None, None]) |
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 | |
class BiMPM(object): | |
''' | |
Bilateral Multi-Perspective Matching Model | |
https://arxiv.org/pdf/1702.03814.pdf | |
''' | |
def __init__(self, state_size, l_perspectives, embeddings_shape): | |
self._state_size = state_size |
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 | |
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 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
# Q-network implementation using linear function aproximator. | |
# Estimates action-value given state and weights matrix Q(a|s,W) | |
import gym | |
import numpy as np | |
import matplotlib.pyplot as plt | |
import time | |
env = gym.make('FrozenLake-v0') |
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
package main | |
import ( | |
"os"; | |
"os/signal"; | |
"syscall"; | |
"time"; | |
"context"; | |
"math"; | |
"bytes"; |
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 random | |
import gym | |
import numpy as np | |
import tensorflow as tf | |
EPOCHS = 250 | |
NUM_GAMES = 100 | |
BATCH_SIZE = 128 | |
MAX_UPDATES = 10 | |
GAMMA = 0.99 |
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 math | |
import random | |
import numpy as np | |
from multiprocessing import Pool, cpu_count | |
def prepend_start(route): | |
return [0] + list(route) | |
def create_population(num_points, size): |
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 os | |
import json | |
from PIL import Image | |
from io import BytesIO | |
from flask import Flask, jsonify, request, render_template, send_file | |
import numpy as np | |
import tensorflow as tf | |
import tensorflow_hub as hub |
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 os | |
from argparse import ArgumentParser | |
from PIL import Image | |
import json | |
import numpy as np | |
import tensorflow as tf | |
import tensorflow_hub as hub | |
from annoy import AnnoyIndex |