From c6ba20c9c8560b6c55b134f17af97403b09dbc0b Mon Sep 17 00:00:00 2001 From: Yuya Unno Date: Fri, 9 Feb 2018 11:24:04 +0900 Subject: [PATCH 1/6] Improve docstring of CTC --- chainer/functions/loss/ctc.py | 25 +++++++++++++++++-------- 1 file changed, 17 insertions(+), 8 deletions(-) diff --git a/chainer/functions/loss/ctc.py b/chainer/functions/loss/ctc.py index 96f0a1c68de9..ed08420933b2 100644 --- a/chainer/functions/loss/ctc.py +++ b/chainer/functions/loss/ctc.py @@ -293,23 +293,32 @@ def connectionist_temporal_classification( Args: x (list or tuple of :class:`~chainer.Variable`): - RNN output at each time. Each element of ``x``, ``x[i]`` - is a :class:`~chainer.Variable` representing output of RNN at time + A list of unnormalized probabilities for labels. + Each element of ``x``, ``x[i]``is a :class:`~chainer.Variable` + object whic has shape ``(B, V)`` where ``B`` + is the batch size and ``V`` is the number of labels. + Softmax of ``x[i]`` represents the probabilities of labels at time ``i``. t (:class:`~chainer.Variable` or :class:`numpy.ndarray` or \ :class:`cupy.ndarray`): Expected label sequence. + Its shape is ``(B, M)`` where ``B`` is the batch size and ``M`` is + the maximum length of the label sequences. + All elements in ``t`` must be lesser than ``V``, the number of + labels. blank_symbol (int): Index of blank_symbol. This value must be non-negative. input_length (:class:`~chainer.Variable` or :class:`numpy.ndarray` or \ - :class:`cupy.ndarray`): - Length of valid sequence for each of mini - batch ``x`` (optional). If input_length is skipped, It regards that + :class:`cupy.ndarray` or ``None``): + Length of valid sequence for each of mini batch ``x`` (optional). + Its shape must be ``(B,)``. + If input_length is skipped, It regards that all of ``x`` is valid input. label_length (:class:`~chainer.Variable` or :class:`numpy.ndarray` or \ - :class:`cupy.ndarray`): - Length of valid sequence for each of mini - batch ``t`` (optional). If label_length is skipped, It regards that + :class:`cupy.ndarray` or ``None``): + Length of valid sequence for each of mini batch ``t`` (optional). + Its shape must be ``(B,)``. + If label_length is skipped, It regards that all of ``t`` is valid input. reduce (str): Reduction option. Its value must be either ``'mean'`` or ``'no'``. Otherwise, From c34d967a1c69b733820895fdbbfaa713fc4258f5 Mon Sep 17 00:00:00 2001 From: Yuya Unno Date: Fri, 9 Feb 2018 11:26:31 +0900 Subject: [PATCH 2/6] Insert a space --- chainer/functions/loss/ctc.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/chainer/functions/loss/ctc.py b/chainer/functions/loss/ctc.py index ed08420933b2..5e9768c3c3c9 100644 --- a/chainer/functions/loss/ctc.py +++ b/chainer/functions/loss/ctc.py @@ -294,7 +294,7 @@ def connectionist_temporal_classification( Args: x (list or tuple of :class:`~chainer.Variable`): A list of unnormalized probabilities for labels. - Each element of ``x``, ``x[i]``is a :class:`~chainer.Variable` + Each element of ``x``, ``x[i]`` is a :class:`~chainer.Variable` object whic has shape ``(B, V)`` where ``B`` is the batch size and ``V`` is the number of labels. Softmax of ``x[i]`` represents the probabilities of labels at time From 874178d2e2b4208569d83955a35ac32bcd690439 Mon Sep 17 00:00:00 2001 From: Yuya Unno Date: Tue, 27 Feb 2018 14:10:05 +0900 Subject: [PATCH 3/6] Fix comments --- chainer/functions/loss/ctc.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/chainer/functions/loss/ctc.py b/chainer/functions/loss/ctc.py index 5e9768c3c3c9..c8d25546f101 100644 --- a/chainer/functions/loss/ctc.py +++ b/chainer/functions/loss/ctc.py @@ -295,16 +295,16 @@ def connectionist_temporal_classification( x (list or tuple of :class:`~chainer.Variable`): A list of unnormalized probabilities for labels. Each element of ``x``, ``x[i]`` is a :class:`~chainer.Variable` - object whic has shape ``(B, V)`` where ``B`` + object which has shape ``(B, V)`` where ``B`` is the batch size and ``V`` is the number of labels. - Softmax of ``x[i]`` represents the probabilities of labels at time - ``i``. + The softmax of ``x[i]`` represents the probabilities of the labels + at time ``i``. t (:class:`~chainer.Variable` or :class:`numpy.ndarray` or \ :class:`cupy.ndarray`): Expected label sequence. Its shape is ``(B, M)`` where ``B`` is the batch size and ``M`` is the maximum length of the label sequences. - All elements in ``t`` must be lesser than ``V``, the number of + All elements in ``t`` must be less than ``V``, the number of labels. blank_symbol (int): Index of blank_symbol. This value must be non-negative. @@ -312,13 +312,13 @@ def connectionist_temporal_classification( :class:`cupy.ndarray` or ``None``): Length of valid sequence for each of mini batch ``x`` (optional). Its shape must be ``(B,)``. - If input_length is skipped, It regards that + If the ``input_length`` is skipped, it assumes that all of ``x`` is valid input. label_length (:class:`~chainer.Variable` or :class:`numpy.ndarray` or \ :class:`cupy.ndarray` or ``None``): Length of valid sequence for each of mini batch ``t`` (optional). Its shape must be ``(B,)``. - If label_length is skipped, It regards that + If the ``label_length`` is skipped, it assumes that all of ``t`` is valid input. reduce (str): Reduction option. Its value must be either ``'mean'`` or ``'no'``. Otherwise, From cd25eee833492caa663518f082d1d7cc2a5dd7a0 Mon Sep 17 00:00:00 2001 From: Yuya Unno Date: Tue, 27 Feb 2018 14:10:59 +0900 Subject: [PATCH 4/6] Insert comma --- chainer/functions/loss/ctc.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/chainer/functions/loss/ctc.py b/chainer/functions/loss/ctc.py index c8d25546f101..b96626c313db 100644 --- a/chainer/functions/loss/ctc.py +++ b/chainer/functions/loss/ctc.py @@ -302,7 +302,7 @@ def connectionist_temporal_classification( t (:class:`~chainer.Variable` or :class:`numpy.ndarray` or \ :class:`cupy.ndarray`): Expected label sequence. - Its shape is ``(B, M)`` where ``B`` is the batch size and ``M`` is + Its shape is ``(B, M)``, where ``B`` is the batch size and ``M`` is the maximum length of the label sequences. All elements in ``t`` must be less than ``V``, the number of labels. From 8702df2b0f4cea4abd072fbb4f6767dd68cf2e47 Mon Sep 17 00:00:00 2001 From: Yuya Unno Date: Tue, 27 Feb 2018 15:09:39 +0900 Subject: [PATCH 5/6] Insert commas --- chainer/functions/loss/ctc.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/chainer/functions/loss/ctc.py b/chainer/functions/loss/ctc.py index b96626c313db..99d8ee07b444 100644 --- a/chainer/functions/loss/ctc.py +++ b/chainer/functions/loss/ctc.py @@ -295,7 +295,7 @@ def connectionist_temporal_classification( x (list or tuple of :class:`~chainer.Variable`): A list of unnormalized probabilities for labels. Each element of ``x``, ``x[i]`` is a :class:`~chainer.Variable` - object which has shape ``(B, V)`` where ``B`` + object, which has shape ``(B, V)``, where ``B`` is the batch size and ``V`` is the number of labels. The softmax of ``x[i]`` represents the probabilities of the labels at time ``i``. From 20debd4563d7d567e38e4cda2b2fd724f09aa70e Mon Sep 17 00:00:00 2001 From: Yuya Unno Date: Mon, 19 Mar 2018 12:01:39 +0900 Subject: [PATCH 6/6] Improve document --- chainer/functions/loss/ctc.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/chainer/functions/loss/ctc.py b/chainer/functions/loss/ctc.py index 99d8ee07b444..d23ed770200f 100644 --- a/chainer/functions/loss/ctc.py +++ b/chainer/functions/loss/ctc.py @@ -310,15 +310,15 @@ def connectionist_temporal_classification( This value must be non-negative. input_length (:class:`~chainer.Variable` or :class:`numpy.ndarray` or \ :class:`cupy.ndarray` or ``None``): - Length of valid sequence for each of mini batch ``x`` (optional). + Length of sequence for each of mini batch ``x`` (optional). Its shape must be ``(B,)``. - If the ``input_length`` is skipped, it assumes that + If the ``input_length`` is omitted or ``None``, it assumes that all of ``x`` is valid input. label_length (:class:`~chainer.Variable` or :class:`numpy.ndarray` or \ :class:`cupy.ndarray` or ``None``): - Length of valid sequence for each of mini batch ``t`` (optional). + Length of sequence for each of mini batch ``t`` (optional). Its shape must be ``(B,)``. - If the ``label_length`` is skipped, it assumes that + If the ``label_length`` is omitted or ``None``, it assumes that all of ``t`` is valid input. reduce (str): Reduction option. Its value must be either ``'mean'`` or ``'no'``. Otherwise,