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 scipy as sp | |
import pandas as pd | |
import matplotlib as mpl | |
import matplotlib.pyplot as plt | |
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
# Countdown | |
function countdown(){ | |
echo "Countdown started: $1 minutes" | |
background_countdown $1 & | |
} | |
function background_countdown(){ | |
date1=$((`date +%s` + $1 * 60)); | |
while [ "$date1" -ge `date +%s` ]; do | |
: | |
done |
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 as tf | |
import tensorflow_datasets as tfds | |
# tfds works with Eager and Graph modes | |
tf.enable_eager_execution() | |
# 0. Select the dataset you'd like to use | |
print(tfds.list_builders()) | |
# 1. Construct the DatasetBuilder |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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_datasets as tfds | |
# Download the dataset and create a tf.data.Dataset | |
ds, info = tfds.load("mnist", split="train", with_info=True) | |
# Access relevant metadata with DatasetInfo | |
print(info.splits["train"].num_examples) | |
print(info.features["label"].num_classes) | |
# Build your input pipeline |
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
# Install: pip install tensorflow-datasets | |
import tensorflow_datasets as tfds | |
mnist_data = tfds.load("mnist") | |
mnist_train, mnist_test = mnist_data["train"], mnist_data["test"] | |
assert isinstance(mnist_train, tf.data.Dataset) |
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_datasets as tfds | |
# Fetch the dataset directly | |
mnist = tfds.image.MNIST() | |
# or by string name | |
mnist = tfds.builder('mnist') | |
# Describe the dataset with DatasetInfo | |
assert mnist.info.features['image'].shape == (28, 28, 1) | |
assert mnist.info.features['label'].num_classes == 10 |
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_datasets as tfds | |
datasets = tfds.load("mnist") | |
train_dataset, test_dataset = datasets["train"], datasets["test"] | |
assert isinstance(train_dataset, tf.data.Dataset) |
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
# See the built-in configs | |
configs = tfds.text.IMDBReviews.builder_configs | |
assert "bytes" in configs | |
# Address a built-in config with tfds.builder | |
imdb = tfds.builder("imdb_reviews/bytes") | |
# or when constructing the builder directly | |
imdb = tfds.text.IMDBReviews(config="bytes") | |
# or use your own custom configuration | |
my_encoder = tfds.features.text.ByteTextEncoder(additional_tokens=['hello']) |
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
imdb = tfds.builder("imdb_reviews/subwords8k") | |
# Get the TextEncoder from DatasetInfo | |
encoder = imdb.info.features["text"].encoder | |
assert isinstance(encoder, tfds.features.text.SubwordTextEncoder) | |
# Encode, decode | |
ids = encoder.encode("Hello world") | |
assert encoder.decode(ids) == "Hello world" |