diff --git a/examples/app-pytorch/client.py b/examples/app-pytorch/client.py index ebbe977ecab1..eb84968bb986 100644 --- a/examples/app-pytorch/client.py +++ b/examples/app-pytorch/client.py @@ -18,7 +18,6 @@ # Define FlowerClient and client_fn class FlowerClient(NumPyClient): - def fit(self, parameters, config): set_weights(net, parameters) results = train(net, trainloader, testloader, epochs=1, device=DEVICE) diff --git a/examples/custom-mods/client.py b/examples/custom-mods/client.py index 2b87a24da19d..614daef6bcf6 100644 --- a/examples/custom-mods/client.py +++ b/examples/custom-mods/client.py @@ -86,7 +86,6 @@ def wandb_mod(msg: Message, context: Context, app: ClientAppCallable) -> Message # if the `ClientApp` just processed a "fit" message, let's log some metrics to W&B if reply.metadata.message_type == MessageType.TRAIN and reply.has_content(): - metrics = reply.content.configs_records results_to_log = dict(metrics.get("fitres.metrics", ConfigsRecord())) diff --git a/examples/quickstart-mlcube/dev/mnist.py b/examples/quickstart-mlcube/dev/mnist.py index e52e2cba85c7..55fb8fae62a7 100644 --- a/examples/quickstart-mlcube/dev/mnist.py +++ b/examples/quickstart-mlcube/dev/mnist.py @@ -36,6 +36,7 @@ def create_directory(path: str) -> None: def download(task_args: List[str]) -> None: """Task: download. + Input parameters: --data_dir """ @@ -81,6 +82,7 @@ def download(task_args: List[str]) -> None: def train(task_args: List[str]) -> None: """Task: train. + Input parameters: --data_dir, --log_dir, --model_dir, --parameters_file """ @@ -175,6 +177,7 @@ def train(task_args: List[str]) -> None: def evaluate(task_args: List[str]) -> None: """Task: train. + Input parameters: --data_dir, --log_dir, --model_dir, --parameters_file """ diff --git a/examples/quickstart-pytorch-lightning/mnist.py b/examples/quickstart-pytorch-lightning/mnist.py index cfee6a3559ad..2f6100fe94cc 100644 --- a/examples/quickstart-pytorch-lightning/mnist.py +++ b/examples/quickstart-pytorch-lightning/mnist.py @@ -84,7 +84,9 @@ def load_data(partition): # 20 % for on federated evaluation partition_full = partition.train_test_split(test_size=0.2, seed=42) # 60 % for the federated train and 20 % for the federated validation (both in fit) - partition_train_valid = partition_full["train"].train_test_split(train_size=0.75, seed=42) + partition_train_valid = partition_full["train"].train_test_split( + train_size=0.75, seed=42 + ) trainloader = DataLoader( partition_train_valid["train"], batch_size=32, diff --git a/examples/vit-finetune/client.py b/examples/vit-finetune/client.py index 68d98926feeb..bf91fa0c4328 100644 --- a/examples/vit-finetune/client.py +++ b/examples/vit-finetune/client.py @@ -8,9 +8,7 @@ class FedViTClient(NumPyClient): - def __init__(self, trainset): - self.trainset = trainset self.model = get_model() diff --git a/examples/vit-finetune/main.py b/examples/vit-finetune/main.py index 1257246304a1..c629a6f68980 100644 --- a/examples/vit-finetune/main.py +++ b/examples/vit-finetune/main.py @@ -19,7 +19,6 @@ def main(): - args = parser.parse_args() # To control the degree of parallelism diff --git a/examples/whisper-federated-finetuning/utils.py b/examples/whisper-federated-finetuning/utils.py index 21fe0309151c..117cf7100ddd 100644 --- a/examples/whisper-federated-finetuning/utils.py +++ b/examples/whisper-federated-finetuning/utils.py @@ -107,10 +107,10 @@ def prepare_silences_dataset(train_dataset, ratio_silence: float = 0.1) -> Datas """Generate silences for the train set. One of the classes in the SpeechCommands datatset is `silence`. However, the dataset - does not include clips of silence. It does however include 5 long files with different - background sounds. The taks of this function is to extract several (defined by `ratio_silence`) - one-second long clips from those background audio files. Later, those audio clips will be - included into the training set. + does not include clips of silence. It does however include 5 long files with + different background sounds. The taks of this function is to extract several + (defined by `ratio_silence`) one-second long clips from those background audio + files. Later, those audio clips will be included into the training set. """ # retrieve original silence audio clips silences = [d for d in train_dataset if d["label"] == 35] @@ -138,9 +138,9 @@ def prepare_silences_dataset(train_dataset, ratio_silence: float = 0.1) -> Datas def construct_client_mapping(full_trainset, num_clients: int = 100): """Create a mapping to partition the dataset into `num_client` buckets. - These buckets contain the same number of `spekaer_id` but likely different - number of training exampes since each `speaker_id` in SpeechCommands does - provide different amounts of data to the dataset. + These buckets contain the same number of `spekaer_id` but likely different number of + training exampes since each `speaker_id` in SpeechCommands does provide different + amounts of data to the dataset. """ client_ids = list(set(full_trainset["speaker_id"])) client_ids.remove( @@ -191,7 +191,7 @@ def set_params(model: torch.nn.ModuleList, params: List[fl.common.NDArrays]): def get_model(device, num_classes, compile: bool = True): - """Create model: Whisper-tiny Encoder + classification head""" + """Create model: Whisper-tiny Encoder + classification head.""" encoder = WhisperForConditionalGeneration.from_pretrained( "openai/whisper-tiny" ).get_encoder() diff --git a/examples/xgboost-comprehensive/dataset.py b/examples/xgboost-comprehensive/dataset.py index 2a5303122ca9..21526b951cfb 100644 --- a/examples/xgboost-comprehensive/dataset.py +++ b/examples/xgboost-comprehensive/dataset.py @@ -27,7 +27,9 @@ def instantiate_partitioner(partitioner_type: str, num_partitions: int): def train_test_split(partition: Dataset, test_fraction: float, seed: int): """Split the data into train and validation set given split rate.""" - train_test = partition.train_test_split(test_size=test_fraction, seed=seed, shuffle=False) + train_test = partition.train_test_split( + test_size=test_fraction, seed=seed, shuffle=False + ) partition_train = train_test["train"] partition_test = train_test["test"]