ConvolutionalNeuralNetwork<T>
Models & Types · AiDotNet.NeuralNetworks
Represents a Convolutional Neural Network (CNN) that processes multi-dimensional data.
Inheritance: NeuralNetworkBase<T> → DeclaredModelLayoutBase<T> → ImageClassifierModelLayoutBase<T> → ConvolutionalNeuralNetwork<T>
For Beginners
Think of a CNN as an image recognition system that works similarly to how your eyes and brain process visual information. Just as your brain automatically notices patterns like edges, shapes, and textures without conscious effort, a CNN automatically learns to detect these features in images. This makes CNNs excellent for tasks like recognizing objects in photos, detecting faces, or reading handwritten text.
How It Works
A Convolutional Neural Network is specialized for processing data with a grid-like structure, such as images. It uses convolutional layers to automatically detect important features without manual feature extraction.
Example
var architecture = new NeuralNetworkArchitecture<float>(inputFeatures: 8, outputSize: 4);
var input = Tensor<float>.CreateRandom(new[] { 1, 3, 32, 32 });
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 ConvolutionalNeuralNetwork<float>(architecture))
.Build(trainX, trainY);
var output = result.Predict(input);
Constructors
| Constructor | Summary |
|---|---|
ConvolutionalNeuralNetwork() |
Initializes a new instance with default architecture settings. |
ConvolutionalNeuralNetwork(NeuralNetworkArchitecture<T> architecture, IGradientBasedOptimizer<T, Tensor<T>, Tensor<T>> optimizer, ILossFunction<T> lossFunction, ConvolutionalNeuralNetworkOptions options) |
Initializes a new instance of the ConvolutionalNeuralNetwork class. |
Methods
| Method | Summary |
|---|---|
ModelMetadata<T> GetModelMetadata() |
Retrieves metadata about the convolutional neural network model. |
Tensor<T> Forward(Tensor<T> input) |
Performs a forward pass through the network with the given input tensor. |
long GetParameterCount() |