NeuralNetwork<T>
Models & Types · AiDotNet.NeuralNetworks
A neural network implementation that processes data through multiple layers to make predictions.
Inheritance: NeuralNetworkBase<T> → DeclaredModelLayoutBase<T> → VectorModelLayoutBase<T> → SequentialVectorModelLayoutBase<T> → NeuralNetwork<T>
Known derived types: BayesianNeuralNetwork<T>, MCDropoutNeuralNetwork<T>
For Beginners
A neural network is like a brain-inspired system that learns from examples.
Think of a neural network as an assembly line for information:
- Input data enters the “factory” (like features of an image or text)
- It passes through several processing stations (layers of neurons)
- Each station transforms the information in specific ways
- Finally, it produces an output (like a prediction or classification)
For example, if you want to classify images of cats and dogs:
- The input would be the pixel values of the image
- The neural network processes these values through its layers
- Each layer learns to recognize different patterns (edges, shapes, textures, etc.)
- The output tells you the probability of the image containing a cat or dog
The network “learns” by adjusting its internal parameters based on examples, gradually improving its predictions through a process called training.
How It Works
Neural networks are computing systems inspired by the human brain. They consist of multiple layers of interconnected nodes (neurons) that process input data to produce predictions. This class provides a straightforward implementation that can be used for various machine learning tasks.
Example
var architecture = new NeuralNetworkArchitecture<float>(
inputType: InputType.OneDimensional,
taskType: NeuralNetworkTaskType.Regression,
inputSize: 10,
outputSize: 2);
var input = Tensor<float>.CreateRandom(new[] { 1, 10 });
var trainX = Tensor<float>.CreateRandom(4, 8);
var trainY = Tensor<float>.CreateRandom(4, 2);
var result = new AiModelBuilder<float, Tensor<float>, Tensor<float>>()
.ConfigureModel(new NeuralNetwork<float>(architecture))
.Build(trainX, trainY);
var output = result.Predict(input);
Constructors
| Constructor | Summary |
|---|---|
NeuralNetwork() |
Creates a new neural network with the specified architecture. |
NeuralNetwork(NeuralNetworkArchitecture<T> architecture, IGradientBasedOptimizer<T, Tensor<T>, Tensor<T>> optimizer, ILossFunction<T> lossFunction, NeuralNetworkDefaultOptions options) |
Properties
| Property | Summary |
|---|---|
bool SupportsTraining { get; } |
Indicates whether this network supports training (learning from data). |
double MaxGradNormValue { get; } |
Initializes the layers of the neural network based on the architecture. |
Methods
| Method | Summary |
|---|---|
ModelMetadata<T> GetModelMetadata() |
Gets metadata about the neural network. |