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. |
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 or in Python using the json
module, then preprocessed using Q#.
- The Microsoft Quantum Development Kit.
This sample can be run in a number of different ways, depending on your preferred environment.
This sample also uses a couple extra Python packages to help out, so you'll need to have those
ready as well. If you are using the Anaconda distribution of Python, this can be done automatically by using
the environment.yml
file provided with this sample:
cd samples/machine-learning/half-moons
conda env create -f environment.yml
conda activate qsharp-sample-classifier
At a terminal, run the following command:
python host.py
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.py: Python code to load data, and to interact with and print out results of the Q# 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.
- HalfMoons.csproj: Main C# project for the sample.
- data.json: JSON-serialized training and validation data used by this sample.