示例#1
0
    def forward(self, xs, ys, reduce='mean', transpose=False):
        """Computes negative log-likelihood of linear-chain CRF

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

        Returns:
            ~chainer.Variable: A variable holding the average negative
            log-likelihood of the input sequences.

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

        if transpose:
            indices = argsort_list_descent(xs)
            xs = permutate_list(xs, indices, inv=False)
            ys = permutate_list(ys, indices, inv=False)
            trans_x = transpose_sequence.transpose_sequence(xs)
            trans_y = transpose_sequence.transpose_sequence(ys)
            loss = crf1d.crf1d(self.cost, trans_x, trans_y, reduce)

        else:
            loss = crf1d.crf1d(self.cost, xs, ys, reduce)

        return loss
示例#2
0
文件: crf1d.py 项目: asi1024/chainer
    def forward(self, xs, ys, reduce='mean', transpose=False):
        """Computes negative log-likelihood of linear-chain CRF

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

        Returns:
            ~chainer.Variable: A variable holding the average negative
            log-likelihood of the input sequences.

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

        if transpose:
            indices = argsort_list_descent(xs)
            xs = permutate_list(xs, indices, inv=False)
            ys = permutate_list(ys, indices, inv=False)
            trans_x = transpose_sequence.transpose_sequence(xs)
            trans_y = transpose_sequence.transpose_sequence(ys)
            loss = crf1d.crf1d(self.cost, trans_x, trans_y, reduce)

        else:
            loss = crf1d.crf1d(self.cost, xs, ys, reduce)

        return loss
示例#3
0
 def forward(self, xs, ys, reduce='mean'):
     return crf1d.crf1d(self.cost, xs, ys, reduce)
示例#4
0
 def __call__(self, xs, ys):
     return crf1d.crf1d(self.cost, xs, ys)
示例#5
0
 def __call__(self, xs, ys, reduce='mean'):
     return crf1d.crf1d(self.cost, xs, ys, reduce)
示例#6
0
文件: crf1d.py 项目: hvy/chainer
 def forward(self, xs, ys, reduce='mean'):
     return crf1d.crf1d(self.cost, xs, ys, reduce)
示例#7
0
文件: crf1d.py 项目: asrlabncku/RAP
 def __call__(self, xs, ys):
     return crf1d.crf1d(self.cost, xs, ys)
示例#8
0
 def __call__(self, xs, ys, reduce='mean'):
     return crf1d.crf1d(self.cost, xs, ys, reduce)