torchsig.models.model_utils.layer_tools.replace_layers_on_conditions

torchsig.models.model_utils.layer_tools.replace_layers_on_conditions(model, condition_factory_pairs)[source]

search through model finding all layers L such that for some ordered pair [conditional_fn, new_layer_factory_fn] in condition_factory_pairs, conditional_fn(L), and replace them with new_layer_factory_fn(L) layers will only be replaced once, so the first conditional for which a layer returns true will be last conditional to which it is compared returns true if at least one layer was replaced; false otherwise