MCPcopy Create free account
hub / github.com/PaddlePaddle/Research / pad_sequences

Function pad_sequences

NLP/Text2SQL-BASELINE/text2sql/utils/nn_utils.py:144–156  ·  view source on GitHub ↗

padding sequences

(seqs, max_len, value=0., dtype=np.int64)

Source from the content-addressed store, hash-verified

142
143
144def pad_sequences(seqs, max_len, value=0., dtype=np.int64):
145 """padding sequences"""
146 data_max_len = 0
147 format_seqs = []
148 for seq in seqs:
149 format_seqs.append(list(seq))
150 data_max_len = len(seq) if len(seq) > data_max_len else data_max_len
151 max_len = min(max_len, data_max_len)
152 padded = []
153 for seq in format_seqs:
154 padded.append(seq[:max_len] + [value] * (max_len - len(seq)))
155 padded = np.array(padded)
156 return padded.astype(dtype)
157
158
159def pad_sequences_for_3d(seqs, max_col, max_num, dtype=np.int64):

Callers

nothing calls this directly

Calls 1

appendMethod · 0.45

Tested by

no test coverage detected