federated/optimization/centralized.py
def centralized_pipeline(
    name: str,
    output: str,
    epochs: int,
    batch_size: int,
    optimizer: str,
    model: str,
    learning_rate: float,
) -> float:
    """Function runs centralized training pipeline.

    Args:
        name (str): Name of the experiment.\n
        output (str): Where to save config files. Defaults to history.\n
        epochs (int): Number of epochs. Defaults to 15.\n
        batch_size (int): Batch size. Defaults to 32.\n
        optimizer (str): Which optimizer to use. Defaults to sgd.\n
        model (str): Which model to use.\n
        learning_rate (float): Learning rate to be used. Defaults to 1.0.\n

    Returns:
        float: Training time after centralized learning.
    """

    model = MODELS[model]()
    optimizer = OPTIMIZERS[optimizer](learning_rate)

    train_dataset, test_dataset, _ = get_datasets(
        train_batch_size=batch_size, centralized=True
    )

    model.compile(
        loss="categorical_crossentropy",
        optimizer=optimizer,
        metrics=["accuracy"],
    )

    _, training_time = centralized_training_loop(
        model,
        train_dataset,
        name,
        epochs,
        output,
        save_model=True,
        validation_dataset=test_dataset,
    )

    return training_time
Function runs centralized training pipeline.

    Args:
        name (str): Name of the experiment.\n
        output (str): Where to save config files. Defaults to history.\n
        epochs (int): Number of epochs. Defaults to 15.\n
        batch_size (int): Batch size. Defaults to 32.\n
        optimizer (str): Which optimizer to use. Defaults to sgd.\n
        model (str): Which model to use.\n
        learning_rate (float): Learning rate to be used. Defaults to 1.0.\n

    Returns:
        float: Training time after centralized learning.
    
Function runs centralized training pipeline.
Function runs centralized training pipeline .
def centralized_pipeline(
    name: str,
    output: str,
    epochs: int,
    batch_size: int,
    optimizer: str,
    model: str,
    learning_rate: float,
) -> float:
    model = MODELS[model]()
    optimizer = OPTIMIZERS[optimizer](learning_rate)
    train_dataset, test_dataset, _ = get_datasets(
        train_batch_size=batch_size, centralized=True
    )
    model.compile(
        loss="categorical_crossentropy",
        optimizer=optimizer,
        metrics=["accuracy"],
    )
    _, training_time = centralized_training_loop(
        model,
        train_dataset,
        name,
        epochs,
        output,
        save_model=True,
        validation_dataset=test_dataset,
    )
    return training_time
def centralized_pipeline ( name : str , output : str , epochs : int , batch_size : int , optimizer : str , model : str , learning_rate : float , ) -> float : model = MODELS [ model ] ( ) optimizer = OPTIMIZERS [ optimizer ] ( learning_rate ) train_dataset , test_dataset , _ = get_datasets ( train_batch_size = batch_size , centralized = True ) model . compile ( loss = "categorical_crossentropy" , optimizer = optimizer , metrics = [ "accuracy" ] , ) _ , training_time = centralized_training_loop ( model , train_dataset , name , epochs , output , save_model = True , validation_dataset = test_dataset , ) return training_time
Function runs centralized training pipeline.
Function runs centralized training pipeline .
"""Function runs centralized training pipeline.

    Args:
        name (str): Name of the experiment.\n
        output (str): Where to save config files. Defaults to history.\n
        epochs (int): Number of epochs. Defaults to 15.\n
        batch_size (int): Batch size. Defaults to 32.\n
        optimizer (str): Which optimizer to use. Defaults to sgd.\n
        model (str): Which model to use.\n
        learning_rate (float): Learning rate to be used. Defaults to 1.0.\n

    Returns:
        float: Training time after centralized learning.
    """
Training time after centralized learning.
Training time after centralized learning .
float
name
str
Name of the experiment.\n
Name of the experiment . \ n
output
str
None
history
epochs
int
Number of epochs. Defaults to 15.\n
Number of epochs . Defaults to 15 . \ n
15
batch_size
int
Batch size. Defaults to 32.\n
Batch size . Defaults to 32 . \ n
32
optimizer
str
Which optimizer to use. Defaults to sgd.\n
Which optimizer to use . Defaults to sgd . \ n
sgd
model
str
Which model to use.\n
Which model to use . \ n
learning_rate
float
Learning rate to be used. Defaults to 1.0.\n
Learning rate to be used . Defaults to 1 . 0 . \ n
1.0