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_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()) |
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_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()) |
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_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()) |
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 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 |
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 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]) |
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 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 |
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 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 |
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 pretrained | |
import tensorflow as tf | |
n_classes = 10 | |
learning_rate = 0.00001 | |
batch_size = 16 | |
conv5 = tf.layers.flatten(pretrained.maxpool5) |
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 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") |
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 pickle | |
import os | |
import math | |
def __extract_file__(fname): | |
with open(fname, 'rb') as fo: | |
d = pickle.load(fo, encoding='bytes') | |
return d |