tfaip.lav¶
LAV¶
Implementation of LAV
-
class
tfaip.lav.lav.MetricsAccumulator¶ Bases:
objectComputation of the running weighted sum (=weighted mean) of a dictionary of float (here the metrics of the scenario) Call final() to access the mean.
-
running_sum¶ The running weighted sum of all values
-
running_weight¶ The sum of all weights
-
__init__()¶ Initialize self. See help(type(self)) for accurate signature.
-
accumulate_dict_sum(new_values: Dict[str, float], sample_weights: Dict[str, float])¶
-
final()¶
-
-
class
tfaip.lav.lav.LAV(params: tfaip.lav.params.LAVParams, data_fn: Callable[], DataBase], model_fn: Callable[], ModelBase], predictor_fn: Callable[[tfaip.predict.params.PredictorParams, DataBase], tfaip.predict.predictor.Predictor], evaluator_fn: Callable[], tfaip.evaluator.evaluator.EvaluatorBase])¶ Bases:
abc.ABCThis is the base Class for Loading And Validation (LAV) a scenario. By default, LAV is independent of the scenario and should therefore not be overridden (but it is possible though in Meta of a Scenario).
LAV will open an exported (or the best) model, create the metrics of the actual scenario. Then predict is called on the model on the DataBase validation(!) set and fed to the metric to obtain results (MetricsAccumulator). During the prediction a models print_evaluate method is called to print informative text.
The first possibility to override LAV is to inherit and use _on_batch_end, _on_sample_end, _on_lav_end with custom parameters. Thus is used for instance to support rendering of attention matrices in atr.transformer.
-
classmethod
params_cls() → Type[tfaip.lav.params.LAVParams]¶
-
__init__(params: tfaip.lav.params.LAVParams, data_fn: Callable[], DataBase], model_fn: Callable[], ModelBase], predictor_fn: Callable[[tfaip.predict.params.PredictorParams, DataBase], tfaip.predict.predictor.Predictor], evaluator_fn: Callable[], tfaip.evaluator.evaluator.EvaluatorBase])¶ Initialize self. See help(type(self)) for accurate signature.
-
run(**kwargs)¶
-
extract_dump_data(sample: tfaip.data.pipeline.definitions.Sample)¶
-
classmethod
MultiLAV¶
Implementation of MultiLAV
-
class
tfaip.lav.multilav.MultiLAV(params: tfaip.lav.params.LAVParams, predictor_fn: Callable[[List[str], tfaip.predict.params.PredictorParams], tfaip.predict.multimodelpredictor.MultiModelPredictor], evaluator: tfaip.evaluator.evaluator.EvaluatorBase, predictor_params: tfaip.predict.params.PredictorParams)¶ Bases:
abc.ABCSimilar to LAV but supports multiple models and voting. Drawback: does not use metrics defined in model (EvaluatorBase and Voter must handle everything)
-
classmethod
params_cls() → Type[tfaip.lav.params.LAVParams]¶
-
__init__(params: tfaip.lav.params.LAVParams, predictor_fn: Callable[[List[str], tfaip.predict.params.PredictorParams], tfaip.predict.multimodelpredictor.MultiModelPredictor], evaluator: tfaip.evaluator.evaluator.EvaluatorBase, predictor_params: tfaip.predict.params.PredictorParams)¶ Initialize self. See help(type(self)) for accurate signature.
-
run(**kwargs)¶
-
extract_dump_data(sample: tfaip.data.pipeline.definitions.Sample)¶
-
classmethod
LAVParams¶
Implementation of the LAVParams
-
class
tfaip.lav.params.LAVParams(pipeline: tfaip.data.databaseparams.DataPipelineParams = <factory>, model_path: Optional[Union[str, List[str]]] = None, device: tfaip.device.device_config.DeviceConfigParams = <factory>, silent: bool = False, store_results: bool = True)¶ Bases:
objectParameters for LAV
-
model_path: Union[str, List[str]] = None¶
-
device: tfaip.device.device_config.DeviceConfigParams¶
-
silent: bool = False¶
-
store_results: bool = True¶
-
__init__(pipeline: tfaip.data.databaseparams.DataPipelineParams = <factory>, model_path: Optional[Union[str, List[str]]] = None, device: tfaip.device.device_config.DeviceConfigParams = <factory>, silent: bool = False, store_results: bool = True) → None¶ Initialize self. See help(type(self)) for accurate signature.
-
classmethod
from_dict(kvs: Optional[Union[dict, list, str, int, float, bool]], *, infer_missing=False) → A¶
-
classmethod
from_json(s: Union[str, bytes, bytearray], *, parse_float=None, parse_int=None, parse_constant=None, infer_missing=False, **kw) → A¶
-
classmethod
schema(*, infer_missing: bool = False, only=None, exclude=(), many: bool = False, context=None, load_only=(), dump_only=(), partial: bool = False, unknown=None) → dataclasses_json.mm.SchemaF[A]¶
-
to_dict(encode_json=False) → Dict[str, Optional[Union[dict, list, str, int, float, bool]]]¶
-
to_json(*, skipkeys: bool = False, ensure_ascii: bool = True, check_circular: bool = True, allow_nan: bool = True, indent: Optional[Union[int, str]] = None, separators: Optional[Tuple[str, str]] = None, default: Optional[Callable] = None, sort_keys: bool = False, **kw) → str¶
-
Callbacks¶
Implementation of a general LAVCallback
-
class
tfaip.lav.callbacks.lav_callback.LAVCallback¶ Bases:
abc.ABCBase class of a callback that can be added to LAV
-
__init__()¶ Initialize self. See help(type(self)) for accurate signature.
-
abstract
on_sample_end(data_generator_params: tfaip.data.databaseparams.DataGeneratorParams, sample)¶
-
abstract
on_lav_end(data_generator_params: tfaip.data.databaseparams.DataGeneratorParams, result)¶
-
Definition of the DumpResultsCallback using in LAV
-
class
tfaip.lav.callbacks.dump_results.DumpResultsCallback(filepath: str)¶ Bases:
tfaip.lav.callbacks.lav_callback.LAVCallbackCallback that dumps all results to a file using pickle.
-
__init__(filepath: str)¶ Initialize self. See help(type(self)) for accurate signature.
-
on_sample_end(data_generator_params: tfaip.data.databaseparams.DataGeneratorParams, sample)¶
-
on_lav_end(data_generator_params: tfaip.data.databaseparams.DataGeneratorParams, result)¶
-