tff.simulation.baselines.emnist.create_character_recognition_task
Stay organized with collections
Save and categorize content based on your preferences.
Creates a baseline task for character recognition on EMNIST.
tff.simulation.baselines.emnist.create_character_recognition_task(
train_client_spec: tff.simulation.baselines.ClientSpec
,
eval_client_spec: Optional[tff.simulation.baselines.ClientSpec
] = None,
model_id: Union[str, tff.simulation.baselines.emnist.CharacterRecognitionModel
] = 'cnn_dropout',
only_digits: bool = False,
cache_dir: Optional[str] = None,
use_synthetic_data: bool = False,
debug_seed: Optional[int] = None
) -> tff.simulation.baselines.BaselineTask
The goal of the task is to minimize the sparse categorical crossentropy
between the output labels of the model and the true label of the image. When
only_digits = True
, there are 10 possible labels (the digits 0-9), while
when only_digits = False
, there are 62 possible labels (both numbers and
letters).
This classification can be done using a number of different models, specified
using the model_id
argument. Below we give a list of the different models
that can be used:
model_id = cnn_dropout
: A moderately sized convolutional network. Uses
two convolutional layers, a max pooling layer, and dropout, followed by two
dense layers.
model_id = cnn
: A moderately sized convolutional network, without any
dropout layers. Matches the architecture of the convolutional network used
by (McMahan et al., 2017) for the purposes of testing the FedAvg algorithm.
model_id = 2nn
: A densely connected network with 2 hidden layers, each
with 200 hidden units and ReLU activations.
Args |
train_client_spec
|
A tff.simulation.baselines.ClientSpec specifying how to
preprocess train client data.
|
eval_client_spec
|
An optional tff.simulation.baselines.ClientSpec
specifying how to preprocess evaluation client data. If set to None , the
evaluation datasets will use a batch size of 64 with no extra
preprocessing.
|
model_id
|
A string identifier for a character recognition model. Must be one
of 'cnn_dropout', 'cnn', or '2nn'. These correspond respectively to a CNN
model with dropout, a CNN model with no dropout, and a densely connected
network with two hidden layers of width 200.
|
only_digits
|
A boolean indicating whether to use the full EMNIST-62 dataset
containing 62 alphanumeric classes (True ) or the smaller EMNIST-10
dataset with only 10 numeric classes (False ).
|
cache_dir
|
An optional directory to cache the downloadeded datasets. If
None , they will be cached to ~/.tff/ .
|
use_synthetic_data
|
A boolean indicating whether to use synthetic EMNIST
data. This option should only be used for testing purposes, in order to
avoid downloading the entire EMNIST dataset.
|
debug_seed
|
An optional integer seed to force deterministic model
initialization. This is intended for unittesting.
|
Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License, and code samples are licensed under the Apache 2.0 License. For details, see the Google Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2024-09-20 UTC.
[null,null,["Last updated 2024-09-20 UTC."],[],[],null,["# tff.simulation.baselines.emnist.create_character_recognition_task\n\n\u003cbr /\u003e\n\n|-------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| [View source on GitHub](https://github.com/tensorflow/federated/blob/v0.87.0 Version 2.0, January 2004 Licensed under the Apache License, Version 2.0 (the) |\n\nCreates a baseline task for character recognition on EMNIST. \n\n tff.simulation.baselines.emnist.create_character_recognition_task(\n train_client_spec: ../../../../tff/simulation/baselines/ClientSpec,\n eval_client_spec: Optional[../../../../tff/simulation/baselines/ClientSpec] = None,\n model_id: Union[str, ../../../../tff/simulation/baselines/emnist/CharacterRecognitionModel] = 'cnn_dropout',\n only_digits: bool = False,\n cache_dir: Optional[str] = None,\n use_synthetic_data: bool = False,\n debug_seed: Optional[int] = None\n ) -\u003e ../../../../tff/simulation/baselines/BaselineTask\n\nThe goal of the task is to minimize the sparse categorical crossentropy\nbetween the output labels of the model and the true label of the image. When\n`only_digits = True`, there are 10 possible labels (the digits 0-9), while\nwhen `only_digits = False`, there are 62 possible labels (both numbers and\nletters).\n\nThis classification can be done using a number of different models, specified\nusing the `model_id` argument. Below we give a list of the different models\nthat can be used:\n\n- `model_id = cnn_dropout`: A moderately sized convolutional network. Uses two convolutional layers, a max pooling layer, and dropout, followed by two dense layers.\n- `model_id = cnn`: A moderately sized convolutional network, without any dropout layers. Matches the architecture of the convolutional network used by (McMahan et al., 2017) for the purposes of testing the FedAvg algorithm.\n- `model_id = 2nn`: A densely connected network with 2 hidden layers, each with 200 hidden units and ReLU activations.\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n| Args ---- ||\n|----------------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| `train_client_spec` | A [`tff.simulation.baselines.ClientSpec`](../../../../tff/simulation/baselines/ClientSpec) specifying how to preprocess train client data. |\n| `eval_client_spec` | An optional [`tff.simulation.baselines.ClientSpec`](../../../../tff/simulation/baselines/ClientSpec) specifying how to preprocess evaluation client data. If set to `None`, the evaluation datasets will use a batch size of 64 with no extra preprocessing. |\n| `model_id` | A string identifier for a character recognition model. Must be one of 'cnn_dropout', 'cnn', or '2nn'. These correspond respectively to a CNN model with dropout, a CNN model with no dropout, and a densely connected network with two hidden layers of width 200. |\n| `only_digits` | A boolean indicating whether to use the full EMNIST-62 dataset containing 62 alphanumeric classes (`True`) or the smaller EMNIST-10 dataset with only 10 numeric classes (`False`). |\n| `cache_dir` | An optional directory to cache the downloadeded datasets. If `None`, they will be cached to `~/.tff/`. |\n| `use_synthetic_data` | A boolean indicating whether to use synthetic EMNIST data. This option should only be used for testing purposes, in order to avoid downloading the entire EMNIST dataset. |\n| `debug_seed` | An optional integer seed to force deterministic model initialization. This is intended for unittesting. |\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n| Returns ------- ||\n|---|---|\n| A [`tff.simulation.baselines.BaselineTask`](../../../../tff/simulation/baselines/BaselineTask). ||\n\n\u003cbr /\u003e"]]