QuantumLayer<T>
Layers · AiDotNet.NeuralNetworks.Layers
Represents a neural network layer that uses quantum computing principles for processing inputs.
Inheritance: LayerBase<T> → QuantumLayer<T>
Implements: IShapeContract
For Beginners
This layer uses concepts from quantum computing to process data in a unique way.
Think of it like a special filter that:
- Transforms regular data into a quantum-like format (similar to how light can be both a wave and a particle)
- Performs calculations that explore multiple possibilities simultaneously
- Converts the results back into standard values that other layers can work with
While traditional neural networks work with definite values, quantum layers work with probabilities and superpositions (being in multiple states at once). This can help the network find patterns that might be missed with traditional approaches.
You don’t need to understand quantum physics to use this layer - just know that it offers a different way of processing information that can be powerful for certain problems.
How It Works
The QuantumLayer implements a simulated quantum circuit that processes input data using quantum rotations and measurements. It transforms classical inputs into quantum states, applies quantum operations, and converts the results back to classical outputs. This approach can potentially capture complex patterns that traditional neural network layers might miss.
Constructors
| Constructor | Summary |
|---|---|
QuantumLayer(int inputSize, int outputSize, int numQubits) |
Initializes a new instance of the QuantumLayer class with specified dimensions. |
Properties
| Property | Summary |
|---|---|
bool SupportsTraining { get; } |
Methods
| Method | Summary |
|---|---|
Dictionary<string, string> GetParameterRoles() |
Returns parameter roles for per-role optimizer configuration (e.g., weight decay exemption for biases). |
IReadOnlyList<OutputAxisContract> OutputAxesFor(int inputRank) |
|
IReadOnlyList<Tensor<T>> GetTrainableParameters() |
Returns all trainable parameter tensors marked with [TrainableParameter]. |
void ClearGradients() |
|
void ResetState() |
Resets the internal state of the quantum layer. |
void SetTrainableParameters(IReadOnlyList<Tensor<T>> parameters) |
Replaces trainable parameter tensors (e.g., with ParameterBuffer views). |
void UpdateParameters(T learningRate) |
|
void ZeroGrad() |
Clears all gradient fields discovered by convention ({paramName}Gradient). |