Zachnad0.UtilLib 3.1.1

dotnet add package Zachnad0.UtilLib --version 3.1.1
NuGet\Install-Package Zachnad0.UtilLib -Version 3.1.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="Zachnad0.UtilLib" Version="3.1.1" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Zachnad0.UtilLib --version 3.1.1
#r "nuget: Zachnad0.UtilLib, 3.1.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 Zachnad0.UtilLib as a Cake Addin
#addin nuget:?package=Zachnad0.UtilLib&version=3.1.1

// Install Zachnad0.UtilLib as a Cake Tool
#tool nuget:?package=Zachnad0.UtilLib&version=3.1.1

ZUtilLib Quick Guide

Note

This library is not specifically intended to be useful really to anyone besides myself, so why I am making a guide is just for fun. And testing formatting. Do note that this library is, and will always be a work in progress, though most of it will be finished to a usable state eventually (of course). Documentation is available for most features.

Basic Utilities

Under the ZUtilLib namespace directly is where the most generic and uncategorizable methods (some extension) are. Basically stuff that's useful for, well, whatever they say they do.

Maths Stuff

Under the namespace ZUtilLib.ZMath a whole bunch of classes, an interface, and methods under those classes can be found. These are all a part of my "Object Oriented Algebraic Calculator" system that I came up with that can do trivial algebraic stuff like substituting variables, or random calculus things like differentiation and integration of equations. As of writing this, integration and division (coming later), have not been implemented. Do note, future self and other readers, that this part of the library is currently entirely undocumented.

AI (Neural Networks)

So instead of using someone else's obscure AI library, I decided to make my own obscure AI library. Stuff for specifically training networks is not provided, but the generating, initializing, deriving, mutating, calculating, and data structures for neural networks is all provided. This is all under the ZUtilLib.ZAI namespace, and will be relatively well documented when it is at a usable state. Activation functions and other stuff is included and utilized internally, so it should be quite easy and effective to customize and use. Below I'll write up a quick tutorial so that I can remember what do to, then wonder why I made it that way.

Basic Neural Network Usage Tutorial

All of these steps are required for the most basic usage of neural networks.

  1. Instantite a new NN: NeuralNetwork testnet = new NeuralNetwork(3, 3, 5, 2, NDNodeActivFunc.ReLU);. Intellisense will show you what the parameter names are, and the documentation assigned to them. Calling the constructor essentially creates a new NN instance of the specified sizes.

  2. Initialize the NN: testNet.InitializeThis();. What this does is generate all of the nodes and links with randomized weights and biases. An optional parameter is a float, for amplifying the randomness.

  3. Calculate the result by passing in the inputs: float[] result = testNet.PerformCalculations(0.2f, 0.3fm 0.4f);. This method takes a params array of the values of the input nodes.

  4. So now you've gotten your results, and scored the neural network or whatever you wish to do. To clone the network you'll have to instantiate a new network with identical specifications: NeuralNetwork secondTestNet = new NeuralNetwork(3, 3, 5, 2, NDNodeActivFunc.ReLU);.

  5. Then clone it via an overload of the InitializeThis method: secondTestNet.InitializeThis(testNet, 1, 1);. The two floats following the network to be cloned determine mutation chance and learning rate for it to be cloned by. There's also an optional bool for if you want the changes to be relative (default off).

Packaging networks for JSON serialization can be done using the PackagedNeuralNetwork struct in ZAI.Saving, by passing the NeuralNetwork into the constructor. Unpack the PackagedNeuralNetwork by passing it into the NeuralNetwork constructor.

Convolutional Neural Network Usage

TODO - Add this sometime.

Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  net6.0 was computed.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 was computed.  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. 
.NET Core netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard2.1 is compatible. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen60 was computed. 
Xamarin.iOS xamarinios was computed. 
Xamarin.Mac xamarinmac was computed. 
Xamarin.TVOS xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
3.1.1 87 4/12/2024
3.1.0 75 4/10/2024
3.0.0 91 1/12/2024
1.3.4 124 11/4/2023
1.3.3 113 10/14/2023
1.3.2 104 10/7/2023
1.3.1 96 9/23/2023
1.2.3 127 9/6/2023
1.2.2 111 8/25/2023
1.2.0 166 8/20/2023
1.1.1 164 8/10/2023
1.0.0 126 8/9/2023

3.1.1:
- ADDED uint[][] ColorMatrixTo32BitARGB(Color[][]) which is rather self explanatory.
- ADDED (byte[][],byte[][],byte[][],byte[][]) SplitColorMatrix(Color[][]) which splits the single color channel into four: R,G,B,A.

3.1.0:
- ADDED PackagedConvNeuralNetwork to ZAI.Saving, which is a json-serializable data structure for saving the data of a convolutional neural network. Essential for actually saving models. Use this struct's constructor to package, and one of the neural net's constructors to un-pack the data.
- RENAMED ConvolutionalNeuralNetworks class to ConvNeuralNetworks. Why did I make it so long initially?
- FIXED some XML documentation.

3.0.0: // This update is quite massive and took forever. That is why I skipped version 2.
- ADDED convolutional neural networks...
- ADDED 5 more activation functions.
- ADDED byte[,].ToFloatMatrix() which converts a matrix of bytes into a matrix of floats.
- ADDED float[,].NormalizeMatrix(bool) that returns a normalized float matrix.
- ADDED float[].NormalizeArray(bool) that returns a normalized float array.
- CHANGED namespace arrangement so that classic NNs are under ZAI.FFNeuralNetworks
- ADDED namespace for convolutional neural networks under ZAI.ConvNeuralNetworks
- CHANGED static class GraphStuff name to Equations
- ADDED System.Random.NextMatrix(int, int, ?bool) that returns a random float matrix of given size.
- ADDED System.Random.NextArray(int, ?bool) that returns a random float array of given size.
- ADDED entire ZMatrix class which has some implicit conversion and operators and stuff for dealing with float matrices.
- ADDED (T[,] OR T[][] OR T[]).Foreach<T>(Action<int, int, T> (just Action<int, T> for array)) that runs an action for each value, utilizing x, y, (i for array) and the value at that point of the matrix (or array).
- ADDED T[,].SetEach<T>(Func<int, int, T, T>) that runs a func overwriting each value, utilizing x, y, and current value in the matrix. (Also available for T[][] and T[])
- ADDED  ZUtils.LCM(double[]) for getting the lowest common multiple.
- ADDED ZUtils.LinesToCharMatrix(string[]) for converting lines of strings into a char matrix.
- ADDED A LOT MORE TO ZUtils, incl. to and from jagged matrix conversions (ridiculously convenient!!!), and accompanying useful stuff. I recommend checking source code for serious usage.

1.3.4:
- ADDED allow decimal number parameter for ZUtils.FilterNumbers.
- FIXED README AI tutorial info to be actually up to date, and finally made it actually markdown instead of HTML.
- FIXED ZAI.Training.NeuralNetTrainingOptions so that the fields LearningRate and MutateChance are changeable (because they should be).
- FIXED ZAI.Training.NeuralNetTrainingOptions so that all of the fields are included for JSON serialization, and there is a JsonConstructor, therefore it is now serializable.

1.3.3:
- FIXED the fact that multithreading was LIMITED TO 1???
- ADDED method for quickly deriving a generation based off an array of pre-existing neural networks.

1.3.2:
- ADDED Greek alphabet, because why not.

1.3.1:
- ADDED Neural network training async task, for training some/an initial network(s) or a new network, against  a provided multi-input and output target function.
- FIXED Random network generation only generating positive initial weights and biases, so amplitude is actually treated as such.
- FIXED Naming outputs (and inputs) is now entirely optional.
- FIXED Calculation inputs are no longer limited between 1 and 0.