page_type | languages | products | description | |||
---|---|---|---|---|---|---|
sample |
|
|
This sample implements using the quantum machine learning library to train a sequential model on the half-moons dataset, parallelizing over target machines. |
This sample uses Q# and the Microsoft.Quantum.MachineLearning library to train a simple sequential model. The model is trained on a half-moons dataset, loaded in C# using the System.Text.Json package, then preprocessed using Q#.
In this sample, the training loop is parallelized over model start points, with each model using its own instance of the full-state quantum simulator. Parallelizing in this way can lead to significantly improved performance, especially when using a large number of cores on a small number of qubits. The actual distribution of parallel tasks is performed using Parallel LINQ (PLINQ) from a C# host.
- The Microsoft Quantum Development Kit.
This sample can be run in a number of different ways, depending on your preferred environment.
At a terminal, run the following command:
dotnet run
Open the folder containing this sample in Visual Studio ("Open a local folder" from the Getting Started screen or "File → Open → Folder..." from the menu bar) and set HalfMoons.csproj
as the startup project.
Press Start in Visual Studio to run the sample.
- Training.qs: Q# code implementing quantum operations for this sample.
- Host.cs: C# code to load data, and to interact with and print out results of the Q# operations for this sample.
- ParallelHalfMoons.csproj: Main C# project for the sample.
- data.json: JSON-serialized training and validation data used by this sample.