Forward and Gradient-Based Convolution Testing #43
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR introduces a suite of unit tests for convolutions.py located within the within the machine learning and signal processing directories. The primary functions in this file involve neural network convolutions, FFT convolutions, gradient convolutions, and different dimension-based convolutions.
Convolution Operations with Varying Input Shapes
Convolve2 and Convolve3 Operations: Convolution operations return the correct output shape for various input matrix sizes, ensuring that both 2D and 3D convolutions handle input dimensions as expected.
Edge Cases: Includes tests for very small input matrices (e.g., 1x1) and scenarios where kernel sizes are large relative to the input, checking for correct handling of these edge cases.
Data Type Handling
Support for Multiple Data Types: Floating-point precision variants (16-bit, 32-bit, 64-bit) are tested to ensure convolutions work correctly across different numerical representations.
Invalid Data Types: Tests ensure that attempting convolution operations with unsupported data types (e.g., integers, complex numbers) correctly raises errors, preventing undefined behavior.
Convolution Parameters Variability
Strides, Padding, Dilation: Parameterized tests cover various configurations of strides, padding, and dilation, verifying that the output shapes match expected values for each configuration.
Kernel Size Variations: Tests with different kernel sizes confirm that the convolution output adjusts appropriately, ensuring flexibility in convolution kernel selection.
Convolution Modes and Domains
Different Convolution Modes: The effect of changing convolution modes (e.g., default, expand) on the output size and behavior is thoroughly tested.
Convolution Domains: Testing across different convolution domains (e.g., spatial, frequency) to validate that the library correctly implements domain-specific convolution logic.
Gradient Computations
Convolution Gradients: Includes tests for gradient computation through convolutions, covering various gradient types (e.g., filter, data, bias gradients) and ensuring gradients are computed correctly with respect to input data.
Error Handling and Robustness
Invalid Configurations: Checks for negative padding, strides, or dilation sizes, ensuring the library robustly handles invalid inputs by raising exceptions.
Complex Number Handling: Explicit tests for operations involving complex numbers, assessing the library's support for complex convolution operations.