コード例 #1
0
ファイル: crf1d.py プロジェクト: yoshihomma/chainer
    def argmax(self, xs, transpose=False):
        """Computes a state that maximizes a joint probability.

        Args:
            xs (list of Variable): Input vector for each label.
            transpose (bool): If ``True``, input/output sequences
            will be sorted in descending order of length.

        Returns:
            tuple: A tuple of :class:`~chainer.Variable` representing each
            log-likelihood and a list representing the argmax path.

        .. seealso:: See :func:`~chainer.frunctions.crf1d_argmax` for more
           detail.

        """

        if transpose:
            indices = argsort_list_descent(xs)
            xs = permutate_list(xs, indices, inv=False)
            trans_x = transpose_sequence.transpose_sequence(xs)
            score, path = crf1d.argmax_crf1d(self.cost, trans_x)

            path = transpose_sequence.transpose_sequence(path)
            path = [p.array for p in path]
            path = permutate_list(path, indices, inv=True)

        else:
            score, path = crf1d.argmax_crf1d(self.cost, xs)

        return score, path
コード例 #2
0
ファイル: crf1d.py プロジェクト: asi1024/chainer
    def argmax(self, xs, transpose=False):
        """Computes a state that maximizes a joint probability.

        Args:
            xs (list of Variable): Input vector for each label.
            transpose (bool): If ``True``, input/output sequences
            will be sorted in descending order of length.

        Returns:
            tuple: A tuple of :class:`~chainer.Variable` representing each
            log-likelihood and a list representing the argmax path.

        .. seealso:: See :func:`~chainer.frunctions.crf1d_argmax` for more
           detail.

        """

        if transpose:
            indices = argsort_list_descent(xs)
            xs = permutate_list(xs, indices, inv=False)
            trans_x = transpose_sequence.transpose_sequence(xs)
            score, path = crf1d.argmax_crf1d(self.cost, trans_x)

            path = transpose_sequence.transpose_sequence(path)
            path = [p.array for p in path]
            path = permutate_list(path, indices, inv=True)

        else:
            score, path = crf1d.argmax_crf1d(self.cost, xs)

        return score, path
コード例 #3
0
    def argmax(self, xs):
        """Computes a state that maximizes a joint probability.

        Args:
            xs (list of Variable): Input vector for each label.

        Returns:
            tuple: A tuple of :class:`~chainer.Variable` representing each
            log-likelihood and a list representing the argmax path.

        .. seealso:: See :func:`~chainer.frunctions.crf1d_argmax` for more
           detail.

        """
        return crf1d.argmax_crf1d(self.cost, xs)
コード例 #4
0
ファイル: crf1d.py プロジェクト: KotaroSetoyama/chainer
    def argmax(self, xs):
        """Computes a state that maximizes a joint probability.

        Args:
            xs (list of Variable): Input vector for each label.

        Returns:
            tuple: A tuple of :class:`~chainer.Variable` representing each
                log-likelihood and a list representing the argmax path.

        .. seealso:: See :func:`~chainer.frunctions.crf1d_argmax` for more
           detail.

        """
        return crf1d.argmax_crf1d(self.cost, xs)
コード例 #5
0
ファイル: crf1d.py プロジェクト: asrlabncku/RAP
 def argmax(self, xs):
     return crf1d.argmax_crf1d(self.cost, xs)