Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
S
scikit-splearn
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
dev
scikit-splearn
Commits
f0288e9f
There was a problem fetching the pipeline summary.
Commit
f0288e9f
authored
7 years ago
by
Denis Arrivault
Browse files
Options
Downloads
Patches
Plain Diff
Upadte cuda tests
parent
ecba9ede
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Pipeline
#
Changes
2
Pipelines
1
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
examples/svd_tests.py
+51
-23
51 additions, 23 deletions
examples/svd_tests.py
splearn/hankel.py
+10
-1
10 additions, 1 deletion
splearn/hankel.py
with
61 additions
and
24 deletions
examples/svd_tests.py
+
51
−
23
View file @
f0288e9f
...
@@ -10,19 +10,33 @@ from timeit import default_timer as timer
...
@@ -10,19 +10,33 @@ from timeit import default_timer as timer
import
numpy
as
np
import
numpy
as
np
def
test_svd
():
def
test_svd
():
d
=
100
d
=
100
0
A
=
np
.
asarray
(
np
.
random
.
randint
(
1
,
10
,(
d
,
d
)),
dtype
=
np
.
float
64
)
A
=
np
.
asarray
(
np
.
random
.
randint
(
1
,
10
,(
d
,
d
)),
dtype
=
np
.
float
32
)
# scipy
# scipy
print
(
"
\n
****************** Scipy
"
)
print
(
"
\n
****************** Scipy
"
)
from
scipy
import
linalg
as
sc_
linalg
from
scipy
.linalg
import
svd
as
sc_
svd
start
=
timer
()
start
=
timer
()
u_sc
,
s_sc
,
v_sc
=
sc_
linalg
.
svd
(
A
)
u_sc
,
s_sc
,
v_sc
=
sc_svd
(
A
)
duration
=
timer
()
-
start
duration
=
timer
()
-
start
print
(
"
SVD scipy :
"
+
str
(
duration
))
print
(
"
SVD scipy :
"
+
str
(
duration
))
print
(
s_sc
)
print
(
s_sc
)
print
(
type
(
s_sc
))
print
(
type
(
s_sc
))
# cupy
print
(
"
\n
****************** Cupy
"
)
import
cupy
as
cp
from
cupy.linalg
import
svd
as
cp_svd
start
=
timer
()
A_cp
=
cp
.
asarray
(
A
)
u_cp
,
s_cp
,
v_cp
=
cp_svd
(
A_cp
)
u_cp
,
s_cp
,
v_cp
=
u_cp
.
get
(),
s_cp
.
get
(),
v_cp
.
get
()
duration
=
timer
()
-
start
print
(
"
SVD cupy :
"
+
str
(
duration
))
print
(
s_cp
)
print
(
A_cp
.
device
)
print
(
type
(
s_cp
))
# scikit-cuda
# scikit-cuda
print
(
"
\n
****************** scikit-cuda
"
)
print
(
"
\n
****************** scikit-cuda
"
)
import
pycuda.autoinit
import
pycuda.autoinit
...
@@ -40,30 +54,44 @@ def test_svd():
...
@@ -40,30 +54,44 @@ def test_svd():
print
(
s_sk
)
print
(
s_sk
)
print
(
type
(
s_sk
))
print
(
type
(
s_sk
))
# tensorflow
# # tensorflow
print
(
"
\n
****************** tensorflow
"
)
# print("\n****************** tensorflow")
import
tensorflow
as
tf
# import tensorflow as tf
from
tensorflow
import
linalg
as
tf_linalg
# start = timer()
start
=
timer
()
# with tf.device("/cpu:0"):
with
tf
.
Session
(
config
=
tf
.
ConfigProto
(
log_device_placement
=
True
))
as
sess
:
# s_tf, u_tf, v_tf = tf.svd(A, compute_uv=True)
s_tf
,
u_tf
,
v_tf
=
tf_linalg
.
svd
(
A
)
# s_tf, u_tf, v_tf = tf.Session().run(s_tf), tf.Session().run(u_tf), tf.Session().run(v_tf)
s_tf
,
u_tf
,
v_tf
=
s_tf
.
eval
(),
u_tf
.
eval
(),
v_tf
.
eval
()
# duration = timer() - start
duration
=
timer
()
-
start
# print("SVD tensorflow CPU : " + str(duration))
print
(
"
SVD tensorflow :
"
+
str
(
duration
))
# print(s_tf)
print
(
s_tf
)
# print(type(s_tf))
print
(
type
(
s_tf
))
# print()
# start = timer()
# with tf.device("/gpu:0"):
# s_tf, u_tf, v_tf = tf.svd(A, compute_uv=True)
# s_tf, u_tf, v_tf = tf.Session().run(s_tf), tf.Session().run(u_tf), tf.Session().run(v_tf)
# duration = timer() - start
# print("SVD tensorflow GPU : " + str(duration))
# print(s_tf)
# print(type(s_tf))
# Theano
# Theano
print
(
"
\n
****************** theano
"
)
print
(
"
\n
****************** theano
"
)
import
theano.tensor
as
T
from
theano
import
function
,
shared
,
tensor
,
config
from
theano
import
function
import
theano.tensor.nlinalg
as
th_linalg
import
theano.tensor.nlinalg
as
th_linalg
x
=
T
.
dmatrix
(
'
x
'
)
x
=
tensor
.
dmatrix
(
'
x
'
)
u
,
s
,
v
=
th_linalg
.
svd
(
x
)
u
,
s
,
v
=
th_linalg
.
svd
(
x
)
f
=
function
([
x
],
(
u
,
s
,
v
))
f
=
function
([
x
],
(
u
,
s
,
v
))
start
=
timer
()
start
=
timer
()
u_th
,
s_th
,
v_th
=
f
(
A
)
u_th
,
s_th
,
v_th
=
f
(
A
)
duration
=
timer
()
-
start
duration
=
timer
()
-
start
# x = shared(np.asarray(A, config.floatX))
# f = function([], th_linalg.svd(x))
# start = timer()
# u_th, s_th, v_th = f()
# duration = timer() - start
print
(
"
SVD theano :
"
+
str
(
duration
))
print
(
"
SVD theano :
"
+
str
(
duration
))
print
(
s_th
)
print
(
s_th
)
print
(
type
(
s_th
))
print
(
type
(
s_th
))
...
...
This diff is collapsed.
Click to expand it.
splearn/hankel.py
+
10
−
1
View file @
f0288e9f
...
@@ -363,8 +363,17 @@ class Hankel(object):
...
@@ -363,8 +363,17 @@ class Hankel(object):
"
the smaller dimension of the Hankel Matrix (
"
+
"
the smaller dimension of the Hankel Matrix (
"
+
str
(
matrix_shape
)
+
"
)
"
)
str
(
matrix_shape
)
+
"
)
"
)
if
not
self
.
sparse
:
if
not
self
.
sparse
:
try
:
import
theano.tensor
as
T
from
theano
import
function
import
theano.tensor.nlinalg
as
th_linalg
x
=
T
.
dmatrix
(
'
x
'
)
u
,
s
,
v
=
th_linalg
.
svd
(
x
)
svd
=
function
([
x
],
(
u
,
s
,
v
))
except
:
from
scipy.linalg
import
svd
hankel
=
self
.
lhankel
[
0
]
hankel
=
self
.
lhankel
[
0
]
[
u
,
s
,
v
]
=
np
.
linalg
.
svd
(
hankel
)
[
u
,
s
,
v
]
=
svd
(
hankel
)
u
=
u
[:,
:
rank
]
u
=
u
[:,
:
rank
]
v
=
v
[:
rank
,
:]
v
=
v
[:
rank
,
:]
# ds = np.zeros((rank, rank), dtype=complex)
# ds = np.zeros((rank, rank), dtype=complex)
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment