Radiate 1.6.1

dotnet add package Radiate --version 1.6.1
NuGet\Install-Package Radiate -Version 1.6.1
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Radiate" Version="1.6.1" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Radiate --version 1.6.1
#r "nuget: Radiate, 1.6.1"
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install Radiate as a Cake Addin
#addin nuget:?package=Radiate&version=1.6.1

// Install Radiate as a Cake Tool
#tool nuget:?package=Radiate&version=1.6.1

.NET port of Rust crate radiate.

Radiate

Nugets.

Build & run examples

dotnet run --project radiate.examples --configuration Release

Overview

Radiate consists of two main concepts:

1. Data pre-processing for model input/output

Radiate input/output data operates through a Tensor object, a 3D float array wrapper which implements linear algebra functionality used throughout the library. To facilitate the pre-processing operations, Radiate uses a TensorFrame - a collection of model feature tensors & target tensors. The TensorFrame allows you to do common data pre-processing operations like Batch, Layer, Shift, Split, Reshape, Pad, Shuffle, Kernel, Transform. These options are held within the TensorFrame for prediction data processing.

  1. Batch - Set a batch size to train on.
  2. Layer - Layer data by n rows.
  3. Split - Split the data into a training set and testing set. Default is 75% split training, 25% testing.
  4. Reshape - Reshape the row vector to a shape of (height, width, depth), useful for images.
  5. Pad - Pad an image Tensor with n zeros.
  6. Shuffle - Shuffle the rows of the dataset randomly.
  7. Kernel - Add kernel transform for the features, possible options are RBF, Polynomial, and Linear (None).
  8. Transform - Transform the feature or/and target data. Options are Normalize, Standardize, OHE (One Hot Encode), and Image (divide data point by 255).

2. Model/Engine configuration

Each AI/ML algorithm comes with its own set of configuration values. See the links above on each algorithm to view specifics.

Make Preditions

After training, the resting model can be put in a PredictionHarness<T> to make live predictions.

var (inputs, targets) = await new XOR().LoadDataSet();

var data = new TensorFrame(features, targets).Transform(Norm.Standardize);

var neuralNet = new MultilayerPerceptron()
    .Layer(new DenseInfo(64, Activation.ReLU))
    .Layer(new DenseInfo(1, Activation.Linear));

var result = neuralNet.Fit(data).Take(100).ToResult();

var model = result.GetModel();

var harness = new PredictionHarness<MultilayerPerceptron>(model, data);
var output = harness.Predict(new float[] { 0f, 1f });

var predictionResult = output.Result;       // The raw output of the model
var classification = output.Classification; // The class of the prediction
var confidence = output.Confidence;         // The regression confidence of the prediction

Random

All random numbers are generated by calling RandomRegistry.GetRandom(). This allows for random seeds to be set for model building.

// Every Random within this scope will use the same seed - resulting in the same result every time.
var (inputs, targets) = await new XOR().LoadDataSet();
RandomRegistry.Using(new Random(11), _ =>
{
    var data = new TensorFrame(features, targets).Transform(Norm.Standardize);

    var nn = new MultilayerPerceptron(grad)
        .Layer(new DenseInfo(64, Activation.ReLU))
        .Layer(new DenseInfo(1, Activation.Linear));

    var result = nn.Fit(data).Take(MaxEpochs).ToResult();
});

Examples

Datasets coming from Radiate.Data

Convolutional Neural Network on MNist handwritten digets dataset

<img src="https://machinelearningmastery.com/wp-content/uploads/2019/02/Plot-of-a-Subset-of-Images-from-the-MNIST-Dataset-1024x768.png" width="300px">

const int FeatureLimit = 5000;
const int BatchSize = 128;
const int MaxEpochs = 10;

var (rawInputs, rawLabels) = await new Mnist(FeatureLimit).GetDataSet();

var data = new TensorFrame(rawInputs, rawLabels)
   .Reshape(new Shape(28, 28, 1))
   .Transform(Norm.Image, Norm.OHE)
   .Batch(BatchSize)
   .Split();

var neuralNet = new MultilayerPerceptron()
   .Maximizing(AccuracyType.Classification)
   .Layer(new ConvInfo(32, 3))
   .Layer(new MaxPoolInfo(2))
   .Layer(new FlattenInfo())
   .Layer(new DenseInfo(64, Activation.Sigmoid))
   .Layer(new SoftmaxInfo(data.OutputCategories))

var result = neuralNet.Fit(data)
    .Take(MaxEpochs)
    .ToResult();

Evolve a string

var target = "Austin, TX";
var codex = Codecs.CharCodex(target.Length);

var engine = Engine.Genetic(codex)
    .SurvivorSelector(new ElitismSelector<CharGene>())
    .Limit(Limits.Accuracy(Target.Length))
    .ToEngine(pheno => pheno.ToCharArray().Zip(Target.ToCharArray())
        .Sum(pair => pair.First == pair.Second ? 1f : 0f));

var str = engine.Fit()
    .Peek(Displays.Metrics)
    .ToModel();
    
Console.WriteLine(str);

More

See the examples for how to use the API.

Product Compatible and additional computed target framework versions.
.NET net8.0 is compatible.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
  • net8.0

    • No dependencies.

NuGet packages (5)

Showing the top 5 NuGet packages that depend on Radiate:

Package Downloads
Souk

Package Description

Radiate.Data

Package Description

Radiate.Extensions

Package Description

Souk.Radiate

Package Description

Radiate.Genetics

Package Description

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
1.6.1 41 4/27/2024
1.6.0 49 4/27/2024
1.5.9 47 4/27/2024
1.5.8 41 4/27/2024
1.5.7 73 4/22/2024
1.5.6 90 4/21/2024
1.5.5 84 4/11/2024
1.5.4 90 3/24/2024
1.5.3 109 2/27/2024
1.5.2 85 2/26/2024
1.5.1 94 2/26/2024
1.5.0 100 1/31/2024
1.4.9 83 1/25/2024
1.4.8 80 1/24/2024
1.4.7 78 1/24/2024
1.4.6 102 1/23/2024
1.4.5 163 12/17/2023
1.4.4 168 8/10/2023
1.4.3 153 8/6/2023
1.4.2 153 6/5/2023
1.4.1 212 3/14/2023
1.4.0 231 3/8/2023
1.3.9 228 3/2/2023
1.3.8 245 3/1/2023
1.3.7 237 2/27/2023
1.3.6 248 2/15/2023
1.3.5 305 11/29/2022
1.3.4 290 11/29/2022
1.3.3 369 11/28/2022
1.3.2 308 11/28/2022
1.3.1 309 11/28/2022
1.3.0 303 11/27/2022
1.2.9 311 11/27/2022
1.2.8 441 11/26/2022
1.2.7 297 11/26/2022
1.2.6 414 7/25/2022
1.2.5 391 7/25/2022
1.2.4 397 7/25/2022
1.2.3 403 7/25/2022
1.2.2 390 7/25/2022
1.2.1 416 6/22/2022
1.2.0 400 6/21/2022
1.1.9 420 6/21/2022
1.1.8 433 6/21/2022
1.1.7 402 6/20/2022
1.1.6 452 4/14/2022
1.1.5 416 4/14/2022
1.1.4 413 4/14/2022
1.1.3 418 4/14/2022
1.1.2 402 4/14/2022
1.1.1 419 4/14/2022
1.1.0 423 4/14/2022
1.0.9 442 2/14/2022
1.0.8 423 2/14/2022
1.0.7 409 2/14/2022
1.0.6 436 1/20/2022
1.0.5 264 1/15/2022
1.0.4 266 1/15/2022
1.0.3 469 1/12/2022
1.0.2 444 1/12/2022
1.0.1 314 1/12/2022
1.0.0 421 1/12/2022