peal.teachers.virelay_teacher

CFKD teacher that gathers human feedback through the ViReLay web GUI.

ViReLay (with CoRelAy for the spectral analysis) is a tool for browsing attribution maps grouped by clusters. This teacher reuses it for counterfactual feedback: for every counterfactual that flipped the student it computes a per-channel relevance vector from the difference of an intermediate student activation between factual and counterfactual, writes ViReLay’s HDF5 dataset, attribution and analysis databases plus a project yaml into base_dir, serves the project and waits for the user to save the selected (i.e. “false”) data point indices as feedback.json. The helper functions and CoRelAy processors in this module are adapted from the ViReLay example scripts.

Functions

append_attributions

Appends attributions to the attribution database file

create_attribution_database

Creates an attribution database file

create_attribution_dataset

Write a sequence of single attributions into a new attribution database.

create_dataset

Creates a new dataset HDF5 file.

make_project

Generates a ViRelAy project file.

meta_analysis

Performs a meta-analysis over the specified attribution data and writes the results into an analysis database.

run_virelay

Serve a ViReLay project until the user has saved their feedback file.

Classes

Absolute

Represents a CoRelAy processor, which computes the absolute value of its input data.

Flatten

Represents a CoRelAy processor, which flattens its input data.

Histogram

Represents a CoRelAy processor, which computes a histogram over its input data.

ImageDataset

All images of one directory as RGB tensors with a dummy label of 0.

Normalize

Represents a CoRelAy processor, which normalizes its input data.

SumChannel

Represents a CoRelAy processor, which sums its input data across channels, i.e., its second axis.

VirelayTeacher

Human teacher whose verdicts come from a ViReLay cluster selection.