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 tensorflow_datasets as tfds | |
(ds_train, ds_test), ds_info = tfds.load( | |
'mnist', | |
split=['train', 'test'], | |
shuffle_files=True, | |
as_supervised=True, | |
with_info=True, |
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 torch | |
import torch.nn as nn | |
import torch.nn.functional as F | |
import torch.optim as optim | |
from torchvision import datasets, transforms | |
from torch.autograd import Variable | |
# Training settings | |
batch_size = 64 |
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 humingbird | |
# creation + prediction in one call | |
prediction = humningbird.Image.predict(, | |
image="digit_9.jpg", | |
labels=["1", "2", "3", "4", "5", "6", "7", "8", "9"] | |
) | |
print(prediction) |
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 humingbird | |
prediction = humingbird.Image.predict( | |
image_path="digit_9.jpg", | |
labels=["1", "2", "3", "4", "5", "6", "7", "8", "9", "10"] # added 10 | |
) | |
print(prediction) |
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 | |
from tensorflow import keras | |
from tensorflow.keras.datasets import imdb | |
from tensorflow.keras.preprocessing.sequence import pad_sequences | |
from tensorflow.keras import Sequential | |
from tensorflow.keras.layers import Embedding, Flatten, Dense | |
import numpy as np | |
import matplotlib.pyplot as plt | |
# Set the number of words to consider as features |
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 glob | |
import io | |
from .. import data | |
class IMDB(data.Dataset): | |
urls = ['http://ai.stanford.edu/~amaas/data/sentiment/aclImdb_v1.tar.gz'] |
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 humingbird | |
prediction = humingbird.Text.predict( | |
text="A example sentence from the dataset", | |
labels=["positive", "negative", "neutral"] | |
) | |
print(prediction) |
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 transformers | |
from transformers import pipeline | |
generator = pipeline('text-generation', model='gpt2') |
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 humingbird | |
content_filter = humingbird.Text.predict( | |
text="our sample text for Humingbird! This is so easy.", | |
labels=["toxic", "not toxic"] | |
) | |
print(content_filter) |
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 transformers | |
from transformers import pipeline | |
import humingbird | |
# load the model | |
generator = pipeline('text-generation', model='gpt2') | |
# generate a sample | |
generation = (generator("I went for a walk today and saw a", max_length=60))[0]['generated_text'] |
OlderNewer