model_tester
model_tester(config, input_dict, output_shape_dict, output_dict_type, output_test_strategy=None, output_equivalence_dict=None)
This functions tests the mdoel using different checks. In order:
- check that model's outputs shapes matched
output_shape_dict
- check that the model can be trained, we use
output_dict_type
to know how to run output's specific tests. For example, for image classification you should passoutput_dict_type=ModelForImageClassificationOutput
and we will try to runoutputs["logits"].mean().backward()
- optionally, if
output_equivalence_dict
we will check that model's outputs match
Parameters:
Name | Type | Description | Default |
---|---|---|---|
config |
Config
|
Configuration we will use to build the model. |
required |
input_dict |
Dict[str, Tensor]
|
Dictionary containing the inputs for the model. E.g. |
required |
output_shape_dict |
Dict[str, Tuple[int]]
|
Dictionary containing the expected shaped in the output. E.g. |
required |
output_dict_type |
TypedDict
|
The type of output, e.g. ModelForImageClassificationOutput](). Used to now which test strategy to run, based on the type we know how to test it. Defaults to None. |
required |
output_test_strategy |
Optional[Callable[[TypedDict]]]
|
If passed, we will use this strategy instead. |
None
|
output_equivalence_dict |
Optional[Dict[str, Tensor]]
|
If passes, we will check that the model's output are equal to the values inside it. Defaults to None. |
None
|