Zachnad0.UtilLib
3.1.0
See the version list below for details.
dotnet add package Zachnad0.UtilLib --version 3.1.0
NuGet\Install-Package Zachnad0.UtilLib -Version 3.1.0
<PackageReference Include="Zachnad0.UtilLib" Version="3.1.0" />
paket add Zachnad0.UtilLib --version 3.1.0
#r "nuget: Zachnad0.UtilLib, 3.1.0"
// Install Zachnad0.UtilLib as a Cake Addin #addin nuget:?package=Zachnad0.UtilLib&version=3.1.0 // Install Zachnad0.UtilLib as a Cake Tool #tool nuget:?package=Zachnad0.UtilLib&version=3.1.0
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.
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.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.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.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);
.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 | Versions 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. |
-
.NETStandard 2.1
- System.Text.Json (>= 7.0.3)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
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.