示例#1
0
 def run_gpu_svd(self, A_val, full_matrices=True, compute_uv=True):
     A = theano.tensor.fmatrix("A")
     f = theano.function(
         [A],
         gpu_svd(A, full_matrices=full_matrices, compute_uv=compute_uv),
         mode=mode_with_gpu,
     )
     return f(A_val)
示例#2
0
    def test_gpu_singular_values(self):
        A = theano.tensor.fmatrix("A")
        f_cpu = theano.function(
            [A], theano.tensor.nlinalg.svd(A, compute_uv=False), mode=mode_without_gpu
        )
        f_gpu = theano.function([A], gpu_svd(A, compute_uv=False), mode=mode_with_gpu)

        A_val = rand(50, 100).astype("float32")
        utt.assert_allclose(f_cpu(A_val), f_gpu(A_val))

        A_val = rand(100, 50).astype("float32")
        utt.assert_allclose(f_cpu(A_val), f_gpu(A_val))
示例#3
0
    def test_gpu_singular_values(self):
        A = theano.tensor.fmatrix("A")
        f_cpu = theano.function(
            [A], theano.tensor.nlinalg.svd(A, compute_uv=False),
            mode=mode_without_gpu)
        f_gpu = theano.function(
            [A], gpu_svd(A, compute_uv=False), mode=mode_with_gpu)

        A_val = rand(50, 100).astype('float32')
        utt.assert_allclose(f_cpu(A_val), f_gpu(A_val))

        A_val = rand(100, 50).astype('float32')
        utt.assert_allclose(f_cpu(A_val), f_gpu(A_val))
示例#4
0
 def run_gpu_svd(self, A_val, full_matrices=True, compute_uv=True):
     A = theano.tensor.fmatrix("A")
     f = theano.function(
         [A], gpu_svd(A, full_matrices=full_matrices, compute_uv=compute_uv),
         mode=mode_with_gpu)
     return f(A_val)