Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
Args:
c: conept name
r: random concept name
bn: the layer name
act_c: activation matrix of the concept in the 'bn' layer
ow: overwrite if CAV already exists
directory: to save the generated CAV
Returns:
The accuracy of the CAV
"""
if directory is None:
directory = self.cav_dir
act_r = self._random_concept_activations(bn, r)
cav_instance = cav.get_or_train_cav([c, r],
bn, {
c: {
bn: act_c
},
r: {
bn: act_r
}
},
cav_dir=directory,
overwrite=ow)
return cav_instance.accuracies['overall']