MCPcopy Create free account
hub / github.com/ChineseGLUE/ChineseGLUE / PaddingInputExample

Class PaddingInputExample

baselines/models/bert/run_classifier.py:153–163  ·  view source on GitHub ↗

Fake example so the num input examples is a multiple of the batch size. When running eval/predict on the TPU, we need to pad the number of examples to be a multiple of the batch size, because the TPU requires a fixed batch size. The alternative is to drop the last batch, which is bad be

Source from the content-addressed store, hash-verified

151
152
153class PaddingInputExample(object):
154 """Fake example so the num input examples is a multiple of the batch size.
155
156 When running eval/predict on the TPU, we need to pad the number of examples
157 to be a multiple of the batch size, because the TPU requires a fixed batch
158 size. The alternative is to drop the last batch, which is bad because it means
159 the entire output data won't be generated.
160
161 We use this class instead of `None` because treating `None` as padding
162 battches could cause silent errors.
163 """
164
165
166class InputFeatures(object):

Callers 1

mainFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected