MCPcopy
hub / github.com/huggingface/transformers / test_training

Method test_training

tests/test_modeling_common.py:1734–1753  ·  tests/test_modeling_common.py::ModelTesterMixin.test_training
(self)

Source from the content-addressed store, hash-verified

1732 )
1733
1734 def test_training(self):
1735 if not self.model_tester.is_training:
1736 self.skipTest(reason=class="st">"ModelTester is not configured to run training tests")
1737
1738 for model_class in self.all_model_classes:
1739 config, inputs_dict = self.model_tester.prepare_config_and_inputs_for_common()
1740 config.return_dict = True
1741
1742 if model_class.__name__ in [
1743 *get_values(MODEL_MAPPING_NAMES),
1744 *get_values(MODEL_FOR_BACKBONE_MAPPING_NAMES),
1745 ]:
1746 continue
1747
1748 model = model_class(config)
1749 model.to(torch_device)
1750 model.train()
1751 inputs = self._prepare_for_class(inputs_dict, model_class, return_labels=True)
1752 loss = model(**inputs).loss
1753 loss.backward()
1754
1755 def test_training_gradient_checkpointing(self):
1756 class="cm"># Scenario - 1 default behaviour

Callers

nothing calls this directly

Calls 6

_prepare_for_classMethod · 0.95
get_valuesFunction · 0.90
toMethod · 0.45
trainMethod · 0.45
backwardMethod · 0.45

Tested by

no test coverage detected