From 5de86bd53d9f6e42b7a618466736c8f2b77362f6 Mon Sep 17 00:00:00 2001 From: danielnugraha Date: Mon, 15 May 2023 09:10:34 +0200 Subject: [PATCH 01/14] add quickstart ios doc --- doc/source/quickstart-ios.rst | 65 +++++++++++++++++++++++++++++++++++ 1 file changed, 65 insertions(+) create mode 100644 doc/source/quickstart-ios.rst diff --git a/doc/source/quickstart-ios.rst b/doc/source/quickstart-ios.rst new file mode 100644 index 000000000000..fb8b384b30ba --- /dev/null +++ b/doc/source/quickstart-ios.rst @@ -0,0 +1,65 @@ +.. _quickstart-pytorch: + + +Quickstart PyTorch +================== + +In this tutorial we will learn how to train a Neural Network on MNIST using Flower and CoreML. + +First of all, it is recommended to create a virtual environment and run everything within a `virtualenv `_. + +Our example consists of one *server* and *clients* that all have the same model. + +*Clients* are responsible for generating individual weight-updates for the model based on their local datasets. +These updates are then sent to the *server* which will aggregate them to produce a better model. Finally, the *server* sends this improved version of the model back to each *client*. +A complete cycle of weight updates is called a *round*. + +Now that we have a rough idea of what is going on, let's get started. We first need to install Flower. You can do this by running : + +.. code-block:: shell + + $ pip install flwr + +Or simply install all dependencies using Poetry: + +.. code-block:: shell + + $ poetry install + +Flower Client +------------- + +Now that we have all our dependencies installed, let's run a simple distributed training. +Please refer to the `full code example `_ to learn more. + + +Flower Server +------------- + +For simple workloads we can start a Flower server and leave all the +configuration possibilities at their default values. In a file named +:code:`server.py`, import Flower and start the server: + +.. code-block:: python + + import flwr as fl + + fl.server.start_server(config=fl.server.ServerConfig(num_rounds=3)) + +Train the model, federated! +--------------------------- + +With both client and server ready, we can now run everything and see federated +learning in action. FL systems usually have a server and multiple clients. We +therefore have to start the server first: + +.. code-block:: shell + + $ python server.py + +Once the server is running we can start the clients in different terminals. +Build and run the client through your Xcode. + +Congratulations! +You've successfully built and run your first federated learning system in your ios device. +The full `source code `_ for this example can be found in :code:`examples/ios`. From a5a94acbf813ffc9f50c8a36cb9c095de66f6c94 Mon Sep 17 00:00:00 2001 From: danielnugraha Date: Wed, 17 May 2023 10:12:35 +0200 Subject: [PATCH 02/14] add flower client content in quickstart-ios --- doc/source/index.rst | 1 + doc/source/quickstart-ios.rst | 79 +++++++++++++++++++++++++++++++---- 2 files changed, 73 insertions(+), 7 deletions(-) diff --git a/doc/source/index.rst b/doc/source/index.rst index 2fef720b15ae..7410bd2375ed 100644 --- a/doc/source/index.rst +++ b/doc/source/index.rst @@ -53,6 +53,7 @@ A learning-oriented series of federated learning tutorials, the best place to st quickstart-mxnet quickstart-scikitlearn quickstart-xgboost + quickstart-ios QUICKSTART TUTORIALS: :ref:`PyTorch ` | :ref:`TensorFlow ` | :ref:`🤗 Transformers ` | :ref:`JAX ` | :ref:`Pandas ` | :ref:`fastai ` | :ref:`PyTorch Lightning ` | :ref:`MXNet ` | :ref:`scikit-learn ` | :ref:`XGBoost ` diff --git a/doc/source/quickstart-ios.rst b/doc/source/quickstart-ios.rst index fb8b384b30ba..559e92d07a7b 100644 --- a/doc/source/quickstart-ios.rst +++ b/doc/source/quickstart-ios.rst @@ -1,7 +1,7 @@ -.. _quickstart-pytorch: +.. _quickstart-ios: -Quickstart PyTorch +Quickstart iOS ================== In this tutorial we will learn how to train a Neural Network on MNIST using Flower and CoreML. @@ -29,10 +29,75 @@ Or simply install all dependencies using Poetry: Flower Client ------------- -Now that we have all our dependencies installed, let's run a simple distributed training. -Please refer to the `full code example `_ to learn more. - - +Now that we have all our dependencies installed, let's run a simple distributed training using CoreML as our local training pipeline and MNIST as our dataset. +For simplicity reasons we will use the complete Flower client with CoreML, that has been implemented and stored inside the Swift SDK. The client implementation can be seen below: +.. code-block:: swift + /// Parses the parameters from the local model and returns them as GetParametersRes struct + /// + /// - Returns: Parameters from the local model + public func getParameters() -> GetParametersRes { + let parameters = parameters.weightsToParameters() + let status = Status(code: .ok, message: String()) + + return GetParametersRes(parameters: parameters, status: status) + } + + /// Calls the routine to fit the local model + /// + /// - Returns: The result from the local training, e.g., updated parameters + public func fit(ins: FitIns) -> FitRes { + let status = Status(code: .ok, message: String()) + let result = runMLTask(configuration: parameters.parametersToWeights(parameters: ins.parameters), task: .train) + let parameters = parameters.weightsToParameters() + + return FitRes(parameters: parameters, numExamples: result.numSamples, status: status) + } + + /// Calls the routine to evaluate the local model + /// + /// - Returns: The result from the evaluation, e.g., loss + public func evaluate(ins: EvaluateIns) -> EvaluateRes { + let status = Status(code: .ok, message: String()) + let result = runMLTask(configuration: parameters.parametersToWeights(parameters: ins.parameters), task: .test) + + return EvaluateRes(loss: Float(result.loss), numExamples: result.numSamples, status: status) + } + +Let's create a new application project in Xcode and add flwr as a dependency in your project. For our application, we will store the logic of our app in :code:`FLiOSModel.swift` and the UI elements in :code:`ContentView.swift`. +We will focus more on :code:`FLiOSModel.swift` in this quickstart. Please refer to the `full code example `_ to learn more about the app. + +Import Flower and CoreML related packages in :code:`FLiOSModel.swift`: +.. code-block:: swift + + import Foundation + import CoreML + import flwr + +Then add the mlmodel to the project simply by drag-and-drop, the mlmodel will be bundled inside the application during deployment to your iOS device. +We need to pass the url to access mlmodel and run CoreML machine learning processes, it can be retrieved by calling the function :code:`Bundle.main.url`. +For the MNIST dataset, we need to preprocess it into :code:`MLBatchProvider` object. The preprocessing is done inside :code:`DataLoader.swift`. + +Since CoreML does not allow the model parameters to be seen before training, and accessing the model parameters during or after the training can only be done by specifying the layer name, +we need to know this informations beforehand, through looking at the model specification, which are written as proto files. The implementation can be seen in :code:`MLModelInspect`. + +After we have all of the necessary informations, let's create our Flower client. +.. code-block:: swift + let compiledModelUrl = try MLModel.compileModel(at: url) + let modelInspect = try MLModelInspect(serializedData: Data(contentsOf: url)) + let layerWrappers = modelInspect.getLayerWrappers() + self.mlFlwrClient = MLFlwrClient(layerWrappers: layerWrappers, + dataLoader: dataLoader, + compiledModelUrl: compiledModelUrl) + +Then start the flower grpc client and start communicating to the server by passing our flower client to the function :code:`startFlwrGRPC`. + +.. code-block:: swift + self.flwrGRPC = FlwrGRPC(serverHost: hostname, serverPort: port) + self.flwrGRPC.startFlwrGRPC(client: self.mlFlwrClient) + +That's it for the client. We only have to implement :code:`Client` or call the provided +:code:`MLFlwrClient` and call :code:`startFlwrGRPC()`. The attribute :code:`hostname` and :code:`port` tells the client which server to connect to. +This can be done by entering the hostname and port in the application before clicking the start button to start the federated learning process. Flower Server ------------- @@ -62,4 +127,4 @@ Build and run the client through your Xcode. Congratulations! You've successfully built and run your first federated learning system in your ios device. -The full `source code `_ for this example can be found in :code:`examples/ios`. +The full `source code `_ for this example can be found in :code:`examples/ios`. From 7fff7dab83809103054014d1faed3744a5c16e0b Mon Sep 17 00:00:00 2001 From: danielnugraha Date: Thu, 25 May 2023 10:39:30 +0200 Subject: [PATCH 03/14] add more code blocks --- doc/source/quickstart-ios.rst | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/doc/source/quickstart-ios.rst b/doc/source/quickstart-ios.rst index 559e92d07a7b..16715533a319 100644 --- a/doc/source/quickstart-ios.rst +++ b/doc/source/quickstart-ios.rst @@ -31,7 +31,9 @@ Flower Client Now that we have all our dependencies installed, let's run a simple distributed training using CoreML as our local training pipeline and MNIST as our dataset. For simplicity reasons we will use the complete Flower client with CoreML, that has been implemented and stored inside the Swift SDK. The client implementation can be seen below: + .. code-block:: swift + /// Parses the parameters from the local model and returns them as GetParametersRes struct /// /// - Returns: Parameters from the local model @@ -67,6 +69,7 @@ Let's create a new application project in Xcode and add flwr as a dependency in We will focus more on :code:`FLiOSModel.swift` in this quickstart. Please refer to the `full code example `_ to learn more about the app. Import Flower and CoreML related packages in :code:`FLiOSModel.swift`: + .. code-block:: swift import Foundation @@ -77,12 +80,28 @@ Then add the mlmodel to the project simply by drag-and-drop, the mlmodel will be We need to pass the url to access mlmodel and run CoreML machine learning processes, it can be retrieved by calling the function :code:`Bundle.main.url`. For the MNIST dataset, we need to preprocess it into :code:`MLBatchProvider` object. The preprocessing is done inside :code:`DataLoader.swift`. +.. code-block:: swift + // prepare train dataset + let trainBatchProvider = DataLoader.trainBatchProvider() { _ in } + + // prepare test dataset + let testBatchProvider = DataLoader.testBatchProvider() { _ in } + + // load them together + let dataLoader = MLDataLoader(trainBatchProvider: trainBatchProvider, testBatchProvider: testBatchProvider) + Since CoreML does not allow the model parameters to be seen before training, and accessing the model parameters during or after the training can only be done by specifying the layer name, we need to know this informations beforehand, through looking at the model specification, which are written as proto files. The implementation can be seen in :code:`MLModelInspect`. After we have all of the necessary informations, let's create our Flower client. + .. code-block:: swift + let compiledModelUrl = try MLModel.compileModel(at: url) + + // inspect the model to be able to access the model parameters + // to access the model we need to know the layer name + // since the model parameters are stored as key value pairs let modelInspect = try MLModelInspect(serializedData: Data(contentsOf: url)) let layerWrappers = modelInspect.getLayerWrappers() self.mlFlwrClient = MLFlwrClient(layerWrappers: layerWrappers, @@ -92,12 +111,14 @@ After we have all of the necessary informations, let's create our Flower client. Then start the flower grpc client and start communicating to the server by passing our flower client to the function :code:`startFlwrGRPC`. .. code-block:: swift + self.flwrGRPC = FlwrGRPC(serverHost: hostname, serverPort: port) self.flwrGRPC.startFlwrGRPC(client: self.mlFlwrClient) That's it for the client. We only have to implement :code:`Client` or call the provided :code:`MLFlwrClient` and call :code:`startFlwrGRPC()`. The attribute :code:`hostname` and :code:`port` tells the client which server to connect to. This can be done by entering the hostname and port in the application before clicking the start button to start the federated learning process. + Flower Server ------------- From 3fc1724c936eceb0b93dc5a9562de20b99abb80b Mon Sep 17 00:00:00 2001 From: danielnugraha Date: Thu, 25 May 2023 14:28:10 +0200 Subject: [PATCH 04/14] add reference to quickstart-ios and add more context to quickstart-ios env setup --- doc/source/index.rst | 2 +- doc/source/quickstart-ios.rst | 15 ++++++++------- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/doc/source/index.rst b/doc/source/index.rst index 7410bd2375ed..3c6e0f78f5d4 100644 --- a/doc/source/index.rst +++ b/doc/source/index.rst @@ -55,7 +55,7 @@ A learning-oriented series of federated learning tutorials, the best place to st quickstart-xgboost quickstart-ios -QUICKSTART TUTORIALS: :ref:`PyTorch ` | :ref:`TensorFlow ` | :ref:`🤗 Transformers ` | :ref:`JAX ` | :ref:`Pandas ` | :ref:`fastai ` | :ref:`PyTorch Lightning ` | :ref:`MXNet ` | :ref:`scikit-learn ` | :ref:`XGBoost ` +QUICKSTART TUTORIALS: :ref:`PyTorch ` | :ref:`TensorFlow ` | :ref:`🤗 Transformers ` | :ref:`JAX ` | :ref:`Pandas ` | :ref:`fastai ` | :ref:`PyTorch Lightning ` | :ref:`MXNet ` | :ref:`scikit-learn ` | :ref:`XGBoost ` | :ref:`iOS ` How-to guides ~~~~~~~~~~~~~ diff --git a/doc/source/quickstart-ios.rst b/doc/source/quickstart-ios.rst index 16715533a319..b421b7ac19b1 100644 --- a/doc/source/quickstart-ios.rst +++ b/doc/source/quickstart-ios.rst @@ -2,25 +2,26 @@ Quickstart iOS -================== +============== -In this tutorial we will learn how to train a Neural Network on MNIST using Flower and CoreML. +In this tutorial we will learn how to train a Neural Network on MNIST using Flower and CoreML in iOS devices. -First of all, it is recommended to create a virtual environment and run everything within a `virtualenv `_. +First of all, for running the flower Python server, it is recommended to create a virtual environment and run everything within a `virtualenv `_. +For the flower client implementation in iOS, it is recommended to use Xcode as our IDE. -Our example consists of one *server* and *clients* that all have the same model. +Our example consists of one Python *server* and iPhone *clients* that all have the same model. *Clients* are responsible for generating individual weight-updates for the model based on their local datasets. These updates are then sent to the *server* which will aggregate them to produce a better model. Finally, the *server* sends this improved version of the model back to each *client*. A complete cycle of weight updates is called a *round*. -Now that we have a rough idea of what is going on, let's get started. We first need to install Flower. You can do this by running : +Now that we have a rough idea of what is going on, let's get started to setup our flower server environment. We first need to install Flower. You can do this by using pip: .. code-block:: shell - $ pip install flwr + $ pip install -r requirements.txt -Or simply install all dependencies using Poetry: +Or Poetry: .. code-block:: shell From 1face45db2d87fcb3a264e05c3ceb401f6a326c9 Mon Sep 17 00:00:00 2001 From: danielnugraha Date: Thu, 25 May 2023 14:29:06 +0200 Subject: [PATCH 05/14] add missing space to code block --- doc/source/quickstart-ios.rst | 1 + 1 file changed, 1 insertion(+) diff --git a/doc/source/quickstart-ios.rst b/doc/source/quickstart-ios.rst index b421b7ac19b1..108f7f6e30c3 100644 --- a/doc/source/quickstart-ios.rst +++ b/doc/source/quickstart-ios.rst @@ -82,6 +82,7 @@ We need to pass the url to access mlmodel and run CoreML machine learning proces For the MNIST dataset, we need to preprocess it into :code:`MLBatchProvider` object. The preprocessing is done inside :code:`DataLoader.swift`. .. code-block:: swift + // prepare train dataset let trainBatchProvider = DataLoader.trainBatchProvider() { _ in } From 2a788957f2802a7bd707a7dc2d22044e749a3847 Mon Sep 17 00:00:00 2001 From: danielnugraha Date: Thu, 25 May 2023 15:07:19 +0200 Subject: [PATCH 06/14] add quickstart ios in readme.md --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index 4f0ad28861f9..97f544fc76d2 100644 --- a/README.md +++ b/README.md @@ -83,6 +83,7 @@ Stay tuned, more tutorials are coming soon. Topics include **Privacy and Securit * [Quickstart (JAX)](https://github.com/adap/flower/tree/main/examples/quickstart_jax) * [Quickstart (scikit-learn)](https://github.com/adap/flower/tree/main/examples/sklearn-logreg-mnist) * [Quickstart (TFLite on Android [code example])](https://github.com/adap/flower/tree/main/examples/android) +* [Quickstart (iOS)](https://github.com/adap/flower/tree/main/examples/ios) ## Flower Baselines From 71b311eabff87fa51c23e7a010e5ab21d6c84d86 Mon Sep 17 00:00:00 2001 From: danielnugraha Date: Thu, 25 May 2023 15:10:27 +0200 Subject: [PATCH 07/14] add consistent capitalization to Flower --- doc/source/quickstart-ios.rst | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/doc/source/quickstart-ios.rst b/doc/source/quickstart-ios.rst index 108f7f6e30c3..a984ff5a7a17 100644 --- a/doc/source/quickstart-ios.rst +++ b/doc/source/quickstart-ios.rst @@ -6,8 +6,8 @@ Quickstart iOS In this tutorial we will learn how to train a Neural Network on MNIST using Flower and CoreML in iOS devices. -First of all, for running the flower Python server, it is recommended to create a virtual environment and run everything within a `virtualenv `_. -For the flower client implementation in iOS, it is recommended to use Xcode as our IDE. +First of all, for running the Flower Python server, it is recommended to create a virtual environment and run everything within a `virtualenv `_. +For the Flower client implementation in iOS, it is recommended to use Xcode as our IDE. Our example consists of one Python *server* and iPhone *clients* that all have the same model. @@ -15,7 +15,7 @@ Our example consists of one Python *server* and iPhone *clients* that all have t These updates are then sent to the *server* which will aggregate them to produce a better model. Finally, the *server* sends this improved version of the model back to each *client*. A complete cycle of weight updates is called a *round*. -Now that we have a rough idea of what is going on, let's get started to setup our flower server environment. We first need to install Flower. You can do this by using pip: +Now that we have a rough idea of what is going on, let's get started to setup our Flower server environment. We first need to install Flower. You can do this by using pip: .. code-block:: shell @@ -82,7 +82,7 @@ We need to pass the url to access mlmodel and run CoreML machine learning proces For the MNIST dataset, we need to preprocess it into :code:`MLBatchProvider` object. The preprocessing is done inside :code:`DataLoader.swift`. .. code-block:: swift - + // prepare train dataset let trainBatchProvider = DataLoader.trainBatchProvider() { _ in } @@ -110,7 +110,7 @@ After we have all of the necessary informations, let's create our Flower client. dataLoader: dataLoader, compiledModelUrl: compiledModelUrl) -Then start the flower grpc client and start communicating to the server by passing our flower client to the function :code:`startFlwrGRPC`. +Then start the Flower grpc client and start communicating to the server by passing our Flower client to the function :code:`startFlwrGRPC`. .. code-block:: swift From b876c3c975efd395b3134f109f954f93dd4527f0 Mon Sep 17 00:00:00 2001 From: danielnugraha Date: Thu, 25 May 2023 15:14:23 +0200 Subject: [PATCH 08/14] fix wrong link to quickstart ios --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 97f544fc76d2..0e197d0e0328 100644 --- a/README.md +++ b/README.md @@ -83,7 +83,7 @@ Stay tuned, more tutorials are coming soon. Topics include **Privacy and Securit * [Quickstart (JAX)](https://github.com/adap/flower/tree/main/examples/quickstart_jax) * [Quickstart (scikit-learn)](https://github.com/adap/flower/tree/main/examples/sklearn-logreg-mnist) * [Quickstart (TFLite on Android [code example])](https://github.com/adap/flower/tree/main/examples/android) -* [Quickstart (iOS)](https://github.com/adap/flower/tree/main/examples/ios) +* [Quickstart (iOS)](https://flower.dev/docs/quickstart-ios.html) ## Flower Baselines From b1b41d2c4430f6cddbae1ac789f645d1a5534543 Mon Sep 17 00:00:00 2001 From: danielnugraha Date: Thu, 25 May 2023 15:15:37 +0200 Subject: [PATCH 09/14] remove - between weight updates --- doc/source/quickstart-ios.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/source/quickstart-ios.rst b/doc/source/quickstart-ios.rst index a984ff5a7a17..77747848702b 100644 --- a/doc/source/quickstart-ios.rst +++ b/doc/source/quickstart-ios.rst @@ -11,7 +11,7 @@ For the Flower client implementation in iOS, it is recommended to use Xcode as o Our example consists of one Python *server* and iPhone *clients* that all have the same model. -*Clients* are responsible for generating individual weight-updates for the model based on their local datasets. +*Clients* are responsible for generating individual weight updates for the model based on their local datasets. These updates are then sent to the *server* which will aggregate them to produce a better model. Finally, the *server* sends this improved version of the model back to each *client*. A complete cycle of weight updates is called a *round*. From e75d8920077f6e5cdba54ce87d133ae2127ed8d7 Mon Sep 17 00:00:00 2001 From: danielnugraha Date: Thu, 25 May 2023 15:26:26 +0200 Subject: [PATCH 10/14] change project setup --- doc/source/quickstart-ios.rst | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/doc/source/quickstart-ios.rst b/doc/source/quickstart-ios.rst index 77747848702b..c1fb1319da07 100644 --- a/doc/source/quickstart-ios.rst +++ b/doc/source/quickstart-ios.rst @@ -19,13 +19,13 @@ Now that we have a rough idea of what is going on, let's get started to setup ou .. code-block:: shell - $ pip install -r requirements.txt + $ pip install flwr Or Poetry: .. code-block:: shell - $ poetry install + $ poetry add flwr Flower Client ------------- From bc2f60127fff0135b88c47558bf20caa28ba835b Mon Sep 17 00:00:00 2001 From: danielnugraha Date: Thu, 25 May 2023 15:30:34 +0200 Subject: [PATCH 11/14] add more context to how many ios clients --- doc/source/quickstart-ios.rst | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/doc/source/quickstart-ios.rst b/doc/source/quickstart-ios.rst index c1fb1319da07..f142841215ab 100644 --- a/doc/source/quickstart-ios.rst +++ b/doc/source/quickstart-ios.rst @@ -9,7 +9,7 @@ In this tutorial we will learn how to train a Neural Network on MNIST using Flow First of all, for running the Flower Python server, it is recommended to create a virtual environment and run everything within a `virtualenv `_. For the Flower client implementation in iOS, it is recommended to use Xcode as our IDE. -Our example consists of one Python *server* and iPhone *clients* that all have the same model. +Our example consists of one Python *server* and two iPhone *clients* that all have the same model. *Clients* are responsible for generating individual weight updates for the model based on their local datasets. These updates are then sent to the *server* which will aggregate them to produce a better model. Finally, the *server* sends this improved version of the model back to each *client*. @@ -146,7 +146,8 @@ therefore have to start the server first: $ python server.py Once the server is running we can start the clients in different terminals. -Build and run the client through your Xcode. +Build and run the client through your Xcode, one through Xcode Simulator and the other by deploying it to your iPhone. +To see more about how to deploy your app to iPhone or Simulator visit `here `. Congratulations! You've successfully built and run your first federated learning system in your ios device. From 72ad6da8540b7715c123953dbec617aa37cf511b Mon Sep 17 00:00:00 2001 From: danielnugraha Date: Thu, 25 May 2023 15:33:01 +0200 Subject: [PATCH 12/14] add missing syntax to link --- doc/source/quickstart-ios.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/source/quickstart-ios.rst b/doc/source/quickstart-ios.rst index f142841215ab..c07e62e31cff 100644 --- a/doc/source/quickstart-ios.rst +++ b/doc/source/quickstart-ios.rst @@ -147,7 +147,7 @@ therefore have to start the server first: Once the server is running we can start the clients in different terminals. Build and run the client through your Xcode, one through Xcode Simulator and the other by deploying it to your iPhone. -To see more about how to deploy your app to iPhone or Simulator visit `here `. +To see more about how to deploy your app to iPhone or Simulator visit `here `_. Congratulations! You've successfully built and run your first federated learning system in your ios device. From a16ffdd924a8abdcad8e0d1615589c45ea340b8d Mon Sep 17 00:00:00 2001 From: danielnugraha Date: Thu, 25 May 2023 15:34:20 +0200 Subject: [PATCH 13/14] update indentation to code block --- doc/source/quickstart-ios.rst | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/doc/source/quickstart-ios.rst b/doc/source/quickstart-ios.rst index c07e62e31cff..75dc4c33979a 100644 --- a/doc/source/quickstart-ios.rst +++ b/doc/source/quickstart-ios.rst @@ -90,7 +90,8 @@ For the MNIST dataset, we need to preprocess it into :code:`MLBatchProvider` obj let testBatchProvider = DataLoader.testBatchProvider() { _ in } // load them together - let dataLoader = MLDataLoader(trainBatchProvider: trainBatchProvider, testBatchProvider: testBatchProvider) + let dataLoader = MLDataLoader(trainBatchProvider: trainBatchProvider, + testBatchProvider: testBatchProvider) Since CoreML does not allow the model parameters to be seen before training, and accessing the model parameters during or after the training can only be done by specifying the layer name, we need to know this informations beforehand, through looking at the model specification, which are written as proto files. The implementation can be seen in :code:`MLModelInspect`. From 5c28d7ebb9a6738679ffaa2ac5e258f2d7c4c67c Mon Sep 17 00:00:00 2001 From: "Daniel J. Beutel" Date: Thu, 25 May 2023 15:57:43 +0200 Subject: [PATCH 14/14] Apply suggestions from code review --- doc/source/quickstart-ios.rst | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/doc/source/quickstart-ios.rst b/doc/source/quickstart-ios.rst index 75dc4c33979a..9a5adc0a45cc 100644 --- a/doc/source/quickstart-ios.rst +++ b/doc/source/quickstart-ios.rst @@ -66,7 +66,7 @@ For simplicity reasons we will use the complete Flower client with CoreML, that return EvaluateRes(loss: Float(result.loss), numExamples: result.numSamples, status: status) } -Let's create a new application project in Xcode and add flwr as a dependency in your project. For our application, we will store the logic of our app in :code:`FLiOSModel.swift` and the UI elements in :code:`ContentView.swift`. +Let's create a new application project in Xcode and add :code:`flwr` as a dependency in your project. For our application, we will store the logic of our app in :code:`FLiOSModel.swift` and the UI elements in :code:`ContentView.swift`. We will focus more on :code:`FLiOSModel.swift` in this quickstart. Please refer to the `full code example `_ to learn more about the app. Import Flower and CoreML related packages in :code:`FLiOSModel.swift`: @@ -111,7 +111,7 @@ After we have all of the necessary informations, let's create our Flower client. dataLoader: dataLoader, compiledModelUrl: compiledModelUrl) -Then start the Flower grpc client and start communicating to the server by passing our Flower client to the function :code:`startFlwrGRPC`. +Then start the Flower gRPC client and start communicating to the server by passing our Flower client to the function :code:`startFlwrGRPC`. .. code-block:: swift