loading data using TensorFlow Datasets and splitting

Viewed 90

e trouble trying to lead data from tensor flow and i am not able to split the data.

Load the dataset binary_alpha_digits from tensorflow_datasets. Split the dataset into 60% for training and 40% for testing.

I have tried:

from matplotlib import pyplot as plt
import tensorflow as tf
from tensorflow.keras import layers
port tensorflow_datasets as tfds

train_ds, test_ds = tfds.load('BinaryAlphaDigits', split=['train', 'test[:40%]'])

and i am getting the error ValueError: Unknown split 'test'. Should be one of ['train'].

appreciate anyone who can help on this thanks

1 Answers

This dataset does not have a test split. You can use slicing to split train set into:

train_ds, test_ds = tfds.load('BinaryAlphaDigits', 
                              split=['train[:60%]', 'train[60%:]'])

60% of the dataset will in train_ds, rest is in test_ds.

Related