Skip to content

Instantly share code, notes, and snippets.

View joeyism's full-sized avatar

Joey joeyism

View GitHub Profile
import tensorflow_hub as hub
import tensorflow as tf
words_to_embed = ["dog", "cat", "sloth"]
elmo = hub.Module("https://tfhub.dev/google/elmo/2")
embedding_tensor = elmo(words_to_embed) # <-- removed other params
with tf.Session() as sess:
sess.run(tf.global_variables_initializer())
import tensorflow_hub as hub
import tensorflow as tf
words_to_embed = ["dog", "cat", "sloth"] # <-- it's a list now, and the name changed
elmo = hub.Module("https://tfhub.dev/google/elmo/2")
embedding_tensor = elmo(words_to_embed, as_dict=True)["word_emb"] # <-- passing in a list instead of [word]
with tf.Session() as sess:
sess.run(tf.global_variables_initializer())
@joeyism
joeyism / ELMo_hub.py
Last active September 27, 2018 20:58
import tensorflow_hub as hub
import tensorflow as tf
word_to_embed = "dog"
elmo = hub.Module("https://tfhub.dev/google/elmo/2")
embedding_tensor = elmo([word_to_embed], as_dict=True)["word_emb"] # Use as_dict because I want the whole dict, then I select "word_emb"
with tf.Session() as sess:
sess.run(tf.global_variables_initializer())
from cifar import Cifar
from tqdm import tqdm
import tensornets as nets
import tensorflow as tf
import numpy as np
import helper
learning_rate = 0.00001
batch_size = 16
no_of_epochs = 100
import tensornets as nets
import tensorflow as tf
learning_rate = 0.00001
n_classes = 10
image_size = 224
inputs = tf.placeholder(tf.float32, [None, image_size, image_size, 3])
outputs = tf.placeholder(tf.float32, [None, n_classes])
from cifar import Cifar
from tqdm import tqdm
import pretrained
import numpy as np
import tensorflow as tf
import helper
n_classes = 10
learning_rate = 0.00001
from cifar import Cifar
from tqdm import tqdm
import pretrained
import tensorflow as tf
import helper
n_classes = 10
learning_rate = 0.00001
batch_size = 16
import pretrained
import tensorflow as tf
n_classes = 10
learning_rate = 0.00001
batch_size = 16
conv5 = tf.layers.flatten(pretrained.maxpool5)
import pretrained
import tensorflow as tf
n_classes = 10
learning_rate = 0.00001
conv5 = tf.layers.flatten(pretrained.maxpool5)
weights = tf.Variable(tf.zeros([9216, n_classes]), name="output_weight")
import numpy as np
import pickle
import os
import math
def __extract_file__(fname):
with open(fname, 'rb') as fo:
d = pickle.load(fo, encoding='bytes')
return d