fuzzy_exp_helpers

Description

Helper functions for experiment evaluating fuzzy logic rules. This includes definition of a standard logic to use. Most functions are based on receiving an experiment config mapping, as is created by Sacred experiments (see respective Sacred experiment script for config format).

Classes

FormulaEvaluator

Evaluate predicates and formulas with intermediate values cached according to a config.

FormulaIDInfo

KeypointsDatasetWithDesc

Wrapper around coco dataset class returning tuples of (descriptor, (image, anns)).

SwapTupleArgs

Swap the two arguments in a tuple.

Functions

cached_eval(descriptors, input_batch, model)

Given descriptors load model outputs either from cache or generate them from input_batch.

default_logdir(conf)

Return the default logging directory root.

default_uncollate(batch_out[, batch_size])

Uncollate a batch of predicate outputs previously collated by torch default_collate

fix_formula_obj(formula_obj, fuzzy_logic_key)

Fix loaded objects from legacy experiments.

formula_spec_to_dir(formula_spec, ...[, ...])

Legacy shortcut for formula_spec_to_idinfo(...).dir.

formula_spec_to_idinfo([formula_spec, ...])

Return a unique infos on the given formula_spec based on the formula, logic, and constants.

formula_trafo_caches_for(formulas_to_cache, ...)

Get caches for formula transformation outputs.

get_data(img_size, dataset_root, split[, ...])

Return data triple of COCO keypoint datasets with output transformed to semantic segmentation of persons.

get_data_loader_for(dataset, loader_setts, ...)

Uncaptured version of get_data_loader.

get_formula(formula_spec, fuzzy_logic_key, ...)

Parse a formula specification to a formula object of the given logic.

get_formula_obj(conf[, parse, formula_spec])

Parse a formula object from the settings in sacred experiment conf or load the original formula object.

get_logic(fuzzy_logic_key[, ...])

Get a fuzzy logic from key and settings.

get_logic_from_conf(conf[, ...])

Prepare a logic object with the correct predicates from given sacred experiment conf.

get_predicates(concept_model_root, ...[, ...])

Get the predicate function: Takes an image and returns a dict with all predicate values.

mask_cache(subdir, results_cache_dir, device)

Standard mask cache.

predicates_cache_for(concept_to_layer, ...)

Provide caches with folder structure <pedestrian_key>/<logic>/*.pt and <concept>/<layer>/*.pt

save_metrics_to(metric_vals[, ...])

Save dict {metric_name: val} to metrics_logdir/metrics.csv and/or using log_scalar method.

to_bool_predicates(config, formula_obj[, ...])

Replace all occurences of predicate variables by a boolean version binarized at thresh_key.