I would like to train two independent TFF models using emnist dataset. Each model should train on a 1000 distinct participants randomly drawn from the dataset.
Code below
emnist_train, emnist_test = tff.simulation.datasets.emnist.load_data()
participants_ids = np.random.choice(a=emnist_train.client_ids,
size=1000,
replace=False)
federated_dataset =
[data_train.create_tf_dataset_for_client(i) for i in participants_ids]
nested_dataset = tf.data.Dataset.from_tensor_slices(federated_dataset)
Trying to save the dataset
tf.data.experimental.save(nested_dataset, 'model_dataset')
the warning below is generated. However, the save is completed.
E tensorflow/core/framework/dataset.cc:89] The Encode() method is not implemented for DatasetVariantWrapper objects.
The problem occurs upon loading the dataset and trying to inspect its contents
dataset = tf.data.experimental.load('model_dataset',
element_spec=
DatasetSpec(collections.OrderedDict([
('label', TensorSpec(shape=(), dtype=tf.int32)),
('pixels', TensorSpec(shape=(28, 28), dtype=tf.float32))]),
TensorShape([])
# verifying elements
for example in dataset:
print(example)
Error below
tensorflow.python.framework.errors_impl.DataLossError: Unable to parse tensor from stored proto.
Trying other methods such as pickle.dump and np.save, all resulted in error below
tensorflow.python.framework.errors_impl.InternalError: Tensorflow type 21 not convertible to numpy dtype.
Is there any good way to save the newly created datasets ?