SyftJob

July 9, 2020 ยท View on GitHub

CLASS

SyftJob

Contents

  • Methods
    • start(chargeDetection:wifiDetection:)
    • onReady(execute:)
    • onError(execute:)
    • onRejected(execute:)
public class SyftJob: SyftJobProtocol

Represents a single training cycle done by the client

Methods

start(chargeDetection:wifiDetection:)

public func start(chargeDetection: Bool = true, wifiDetection: Bool = true)

Starts the job executing the following actions:

  1. Meters connection speed to PyGrid
  2. Registers into training cycle on PyGrid
  3. Retrieves cycle and client parameters.
  4. Downloads Plans, Model and Protocols.
  5. Triggers onReady handler
  • Parameters:
    • chargeDetection: Specifies whether to check if device is charging before continuing job execution. Default is true.
    • wifiDetection: Specifies whether to have wifi connection before continuing job execution. Default is true.

Parameters

NameDescription
chargeDetectionSpecifies whether to check if device is charging before continuing job execution. Default is true.
wifiDetectionSpecifies whether to have wifi connection before continuing job execution. Default is true.

onReady(execute:)

public func onReady(execute: @escaping (_ plan: SyftPlan, _ clientConfig: FederatedClientConfig, _ report: ModelReport) -> Void)

Registers a closure to execute when the job is accepted into a training cycle.

  • Parameter execute: Closure that accepts the training plan (SyftPlan), training configuration (FederatedClientConfig) and reporting closure (ModelReport). All of these objects will be used during training.
  • parameter plan: SyftPlan use this to train your model and generate diffs
  • parameter clientConfig: contains training configuration such as batch size and learning rate.
  • parameter report: closure that accepts diffs as Data and sends them to PyGrid.

Parameters

NameDescription
executeClosure that accepts the training plan (SyftPlan), training configuration (FederatedClientConfig) and reporting closure (ModelReport). All of these objects will be used during training.
planSyftPlan use this to train your model and generate diffs
clientConfigcontains training configuration such as batch size and learning rate.
reportclosure that accepts diffs as Data and sends them to PyGrid.

onError(execute:)

public func onError(execute: @escaping (_ error: Error) -> Void)

Registers a closure to execute whenever an error occurs during training cycle

  • Parameter execute: closure to execute during training cycle
  • parameter error: contains information about error that occurred

Parameters

NameDescription
executeclosure to execute during training cycle
errorcontains information about error that occurred

onRejected(execute:)

public func onRejected(execute: @escaping (_ timeout: TimeInterval?) -> Void)

Registers a closure to execute whenever an error occurs during training cycle

  • Parameter execute: closure to execute during training cycle
  • parameter timeout: how long you need to wait before trying again

Parameters

NameDescription
executeclosure to execute during training cycle
timeouthow long you need to wait before trying again