Last active
January 25, 2019 17:24
-
-
Save andersx/55dc3ac1fd6d81083b31bd6924aadf39 to your computer and use it in GitHub Desktop.
Test SVD from QML
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/env python3 | |
| from __future__ import print_function | |
| import numpy as np | |
| import qml | |
| from qml.math import svd_solve | |
| from time import time | |
| from scipy.linalg import lstsq | |
| print("Generating random matrix") | |
| height = 10000 | |
| width = 2000 | |
| M = np.random.rand(height, width) | |
| V = np.random.rand(height) | |
| print(M.shape) | |
| print(V.shape) | |
| print("QML solver") | |
| start = time() | |
| alpha = svd_solve(M, V) | |
| end = time() | |
| print(end-start) | |
| print("SciPy solver") | |
| start = time() | |
| alpha = lstsq(M, V, lapack_driver="gelsd") | |
| end = time() | |
| print(end-start) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment