Skip to content

Commit 30ed753

Browse files
committed
update README
1 parent 8ec6468 commit 30ed753

1 file changed

Lines changed: 29 additions & 0 deletions

File tree

README.md

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,36 @@ attributions = tpcav_model.layer_attributions(pack_data_iters(random_regions_1),
9393
bed_cav_trainer.tpcav_score_all_concepts_log_ratio(attributions)
9494
```
9595

96+
## Output
9697

98+
The results of TPCAV are stored in `CavTrainer` object, it contains the F-score of each concept, the corresponding concept activation vector (CAV), and the model object decorated by TPCAV parameters & functions, given the example in Quick Usage:
99+
100+
```python
101+
cav_trainer = motif_cav_trainers[0] # here we take the first motif cav trainer that correponds to the first number of motif insertions
102+
# retrieve F-scores
103+
motif_cav_trainers[0].cav_fscores
104+
# retrieve CAVs
105+
motif_cav_trainers[0].cav_weights
106+
```
107+
108+
You can also retrieve the model decorated by TPCAV parameters by
109+
110+
```python
111+
tpcav_mode = cav_trainer.tpcav
112+
```
113+
114+
So that you can compute attributions for new inputs
115+
116+
```python
117+
# compute layer attributions, and compute new tpcav score
118+
attrs = tpcav_model.layer_attributions(target_batches, baseline_batches)
119+
cav_trainer.tpcav_score_all_concepts_log_ratio(attrs)
120+
121+
# input attributions
122+
input_attrs = tpcav_model.input_attributions(target_batches, baseline_batches, multiply_by_inputs=True,)
123+
# or concept specific input attributions (parts explained by the provided concepts CAVs)
124+
input_attrs = tpcav_model.input_attributions(target_batches, baseline_batches, multiply_by_inputs=True, cavs_list=[cav_trainer.cav_weights[concept_name])
125+
```
97126

98127
If you find any issue, feel free to open an issue (strongly suggested) or contact [Jianyu Yang](mailto:jmy5455@psu.edu).
99128

0 commit comments

Comments
 (0)