Skip to content

Commit ef8b0c9

Browse files
authored
Fix namedtuple generated documentation (#2130)
* Fix namedtuple generated documentation Use "Attributes" block to document attributes. * Format with black 19.10b0
1 parent eab8dea commit ef8b0c9

File tree

3 files changed

+21
-26
lines changed

3 files changed

+21
-26
lines changed

tensorflow_addons/seq2seq/attention_wrapper.py

+6-7
Original file line numberDiff line numberDiff line change
@@ -1366,18 +1366,17 @@ class AttentionWrapperState(
13661366
):
13671367
"""`namedtuple` storing the state of a `AttentionWrapper`.
13681368
1369-
Contains:
1370-
1371-
- `cell_state`: The state of the wrapped RNN cell at the previous time
1369+
Attributes:
1370+
cell_state: The state of the wrapped RNN cell at the previous time
13721371
step.
1373-
- `attention`: The attention emitted at the previous time step.
1374-
- `alignments`: A single or tuple of `Tensor`(s) containing the
1372+
attention: The attention emitted at the previous time step.
1373+
alignments: A single or tuple of `Tensor`(s) containing the
13751374
alignments emitted at the previous time step for each attention
13761375
mechanism.
1377-
- `alignment_history`: (if enabled) a single or tuple of `TensorArray`(s)
1376+
alignment_history: (if enabled) a single or tuple of `TensorArray`(s)
13781377
containing alignment matrices from all time steps for each attention
13791378
mechanism. Call `stack()` on each to convert to a `Tensor`.
1380-
- `attention_state`: A single or tuple of nested objects
1379+
attention_state: A single or tuple of nested objects
13811380
containing attention mechanism state for each attention mechanism.
13821381
The objects may contain Tensors or TensorArrays.
13831382
"""

tensorflow_addons/seq2seq/basic_decoder.py

+3-4
Original file line numberDiff line numberDiff line change
@@ -31,12 +31,11 @@ class BasicDecoderOutput(
3131
):
3232
"""Outputs of a `BasicDecoder` step.
3333
34-
Contains:
35-
36-
- `rnn_output`: The output for this step. If the `output_layer` argument
34+
Attributes:
35+
rnn_output: The output for this step. If the `output_layer` argument
3736
of `BasicDecoder` was set, it is the output of this layer, otherwise it
3837
is the output of the RNN cell.
39-
- `sample_id`: The token IDs sampled for this step, as returned by the
38+
sample_id: The token IDs sampled for this step, as returned by the
4039
`sampler` instance passed to `BasicDecoder`.
4140
"""
4241

tensorflow_addons/seq2seq/beam_search_decoder.py

+12-15
Original file line numberDiff line numberDiff line change
@@ -46,16 +46,15 @@ class BeamSearchDecoderState(
4646
):
4747
"""State of a `BeamSearchDecoder`.
4848
49-
Contains:
50-
51-
- `cell_state`: The cell state returned at the previous time step.
52-
- `log_probs`: The accumulated log probabilities of each beam.
49+
Attributes:
50+
cell_state: The cell state returned at the previous time step.
51+
log_probs: The accumulated log probabilities of each beam.
5352
A `float32` `Tensor` of shape `[batch_size, beam_width]`.
54-
- `finished`: The finished status of each beam.
53+
finished: The finished status of each beam.
5554
A `bool` `Tensor` of shape `[batch_size, beam_width]`.
56-
- `lengths`: The accumulated length of each beam.
55+
lengths: The accumulated length of each beam.
5756
An `int64` `Tensor` of shape `[batch_size, beam_width]`.
58-
- `accumulated_attention_prob`: Accumulation of the attention
57+
accumulated_attention_prob: Accumulation of the attention
5958
probabilities (used to compute the coverage penalty)
6059
"""
6160

@@ -69,19 +68,18 @@ class BeamSearchDecoderOutput(
6968
):
7069
"""Outputs of a `BeamSearchDecoder` step.
7170
72-
Contains:
73-
74-
- `scores`: The scores this step, which are the log
71+
Attributes:
72+
scores: The scores this step, which are the log
7573
probabilities over the output vocabulary, possibly penalized by length
7674
and attention coverage. When `BeamSearchDecoder` is created with
7775
`output_all_scores=False` (default), this will be a `float32` `Tensor`
7876
of shape `[batch_size, beam_width]` containing the top scores
7977
corresponding to the predicted IDs. When `output_all_scores=True`,
8078
this contains the scores for all token IDs and has shape
8179
`[batch_size, beam_width, vocab_size]`.
82-
- `predicted_ids`: The token IDs predicted for this step.
80+
predicted_ids: The token IDs predicted for this step.
8381
A `int32` `Tensor` of shape `[batch_size, beam_width]`.
84-
- `parent_ids`: The indices of the parent beam of each beam.
82+
parent_ids: The indices of the parent beam of each beam.
8583
A `int32` `Tensor` of shape `[batch_size, beam_width]`.
8684
"""
8785

@@ -93,10 +91,9 @@ class FinalBeamSearchDecoderOutput(
9391
"FinalBeamDecoderOutput", ["predicted_ids", "beam_search_decoder_output"]
9492
)
9593
):
96-
"""Final outputs returned by the beam search after all decoding is
97-
finished.
94+
"""Final outputs returned by the beam search after all decoding is finished.
9895
99-
Args:
96+
Attributes:
10097
predicted_ids: The final prediction. A tensor of shape
10198
`[batch_size, T, beam_width]` (or `[T, batch_size, beam_width]` if
10299
`output_time_major` is True). Beams are ordered from best to worst.

0 commit comments

Comments
 (0)