Handle Non-Invertible Matrix

Use unique matrix.
Create method to get gradient.