Skip to content

Instantly share code, notes, and snippets.

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,
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
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)
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)
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
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']
import humingbird
prediction = humingbird.Text.predict(
text="A example sentence from the dataset",
labels=["positive", "negative", "neutral"]
)
print(prediction)
import transformers
from transformers import pipeline
generator = pipeline('text-generation', model='gpt2')
import humingbird
content_filter = humingbird.Text.predict(
text="our sample text for Humingbird! This is so easy.",
labels=["toxic", "not toxic"]
)
print(content_filter)
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']