Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

tf dataset

import tensorflow as tf
# Ensure TF does not see GPU and grab all GPU memory.
tf.config.set_visible_devices([], device_type='GPU')

import tensorflow_datasets as tfds

data_dir = '/tmp/tfds'

# Fetch full datasets for evaluation
# tfds.load returns tf.Tensors (or tf.data.Datasets if batch_size != -1)
# You can convert them to NumPy arrays (or iterables of NumPy arrays) with tfds.dataset_as_numpy
mnist_data, info = tfds.load(name="mnist", batch_size=-1, data_dir=data_dir, with_info=True)
mnist_data = tfds.as_numpy(mnist_data)
train_data, test_data = mnist_data['train'], mnist_data['test']
num_labels = info.features['label'].num_classes
h, w, c = info.features['image'].shape
num_pixels = h * w * c

# Full train set
train_images, train_labels = train_data['image'], train_data['label']
train_images = jnp.reshape(train_images, (len(train_images), num_pixels))
train_labels = one_hot(train_labels, num_labels)

# Full test set
test_images, test_labels = test_data['image'], test_data['label']
test_images = jnp.reshape(test_images, (len(test_images), num_pixels))
test_labels = one_hot(test_labels, num_labels)
Comment

PREVIOUS NEXT
Code Example
Python :: scrapy with selenium 
Python :: all function in python 
Python :: single line return python 
Python :: for schleife python 
Python :: Python NumPy delete Function Example 
Python :: create payment request in stripe 
Python :: can we use else without if in python 
Python :: django password hashers 
Python :: what does abs do in python 
Python :: python webview 
Python :: python - 
Python :: variable referenced before assignment python 
Python :: windows task scheduler python script 
Python :: standard error of mean 
Python :: run only few test cases in pytest 
Python :: service 
Python :: type of tuple in python 
Python :: .extend python 
Python :: deque in python 
Python :: sort a dataframe 
Python :: pk django 
Python :: how to make loop python 
Python :: python dictionaries 
Python :: site:*.instagram.com 
Python :: conda 
Python :: InsertionSort 
Python :: using pickle to create binary files 
Python :: pandas datafdrame pyplot 
Python :: analyser.polarity_scores get only compound 
Python :: python you bad 
ADD CONTENT
Topic
Content
Source link
Name
8+6 =