Exemple #1
0
    def __init__(self, compute_grad=True):
        if not ctc_available():
            raise RuntimeError('Baidu CTC is not available and '
                               'GpuConnectionistTemporalClassification Op '
                               'can not be constructed.')

        self.compute_grad = compute_grad
        # Return only the cost. Gradient will be returned by grad()
        self.default_output = 0

        gof.COp.__init__(self, self.func_file, self.func_name)
Exemple #2
0
    def __init__(self, compute_grad=True):
        if not ctc_available():
            raise RuntimeError('Baidu CTC is not available and '
                               'GpuConnectionistTemporalClassification Op '
                               'can not be constructed.')

        self.compute_grad = compute_grad
        # Return only the cost. Gradient will be returned by grad()
        self.default_output = 0

        gof.COp.__init__(self, self.func_file, self.func_name)
Exemple #3
0
 def setUp(self):
     if not ctc_available():
         self.skipTest('Optional library warp-ctc not available')
Exemple #4
0
 def setUp(self):
     if not ctc_available():
         self.skipTest('Optional library warp-ctc not available')
Exemple #5
0
 def setup_method(self):
     if not ctc_available():
         pytest.skip("Optional library warp-ctc not available")
Exemple #6
0
from theano.tensor.nnet.ctc import (
    ctc,
    ctc_available,
    ConnectionistTemporalClassification,
)

from tests import unittest_tools as utt
from tests.gpuarray.config import mode_with_gpu, mode_without_gpu
from tests.tensor.nnet.test_ctc import (
    setup_torch_case,
    setup_ctc_case,
    setup_grad_case,
)


@pytest.mark.skipif(not ctc_available(),
                    reason="Optional library warp-ctc not available")
class TestCTC:
    def check_ctc(self, activations, labels, input_length, expected_costs,
                  expected_grads):
        # Create symbolic variables
        t_activations = theano.shared(activations, name="activations")
        t_activation_times = theano.shared(input_length,
                                           name="activation_times")
        t_labels = theano.shared(labels, name="labels")

        inputs = [t_activations, t_labels, t_activation_times]

        # Execute several tests for each test case
        self.check_expected_values(t_activations, t_labels, t_activation_times,
                                   expected_costs, expected_grads)
Exemple #7
0
import theano
import theano.gpuarray
import theano.tensor as tt
from tests import unittest_tools as utt
from tests.gpuarray.config import mode_with_gpu, mode_without_gpu
from tests.tensor.nnet.test_ctc import setup_ctc_case, setup_grad_case, setup_torch_case
from theano.gpuarray.ctc import GpuConnectionistTemporalClassification, gpu_ctc
from theano.tensor.nnet.ctc import (
    ConnectionistTemporalClassification,
    ctc,
    ctc_available,
)


@pytest.mark.skipif(
    not ctc_available(), reason="Optional library warp-ctc not available"
)
class TestCTC:
    def check_ctc(
        self, activations, labels, input_length, expected_costs, expected_grads
    ):
        # Create symbolic variables
        t_activations = theano.shared(activations, name="activations")
        t_activation_times = theano.shared(input_length, name="activation_times")
        t_labels = theano.shared(labels, name="labels")

        inputs = [t_activations, t_labels, t_activation_times]

        # Execute several tests for each test case
        self.check_expected_values(
            t_activations, t_labels, t_activation_times, expected_costs, expected_grads
Exemple #8
0
    def setUp(self):
        if theano.config.mode == "FAST_COMPILE" or theano.config.cxx == "":
            raise SkipTest("We need a c compiler")

        if not ctc_available():
            self.skipTest('Optional library warp-ctc not available')
Exemple #9
0
    def setup_method(self):
        if theano.config.mode == "FAST_COMPILE" or theano.config.cxx == "":
            pytest.skip("We need a c compiler")

        if not ctc_available():
            pytest.skip("Optional library warp-ctc not available")
    def setUp(self):
        if theano.config.mode == "FAST_COMPILE" or theano.config.cxx == "":
            raise SkipTest("We need a c compiler")

        if not ctc_available():
            self.skipTest('Optional library warp-ctc not available')