Skip to content

Payload

Payloads define the possible content types that are going to be visualised when building an explanation. Payloads are required in every node of a GAF to hold information about the content and content type.

Content Types

Payloads can represent and hold the content types:

1
2
3
4
class PayloadType(str, Enum):
    STRING = 'string'
    IMAGE = 'image'
    IMAGE_PAIR = 'image_pair'

Example Usage

Example for creation of payloads by the activation maximization Chi for a single GAF node, used in explaining a convolutional neural network prediction.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
def generate(self, x, node, model):
        img_dims = (x.shape[2], x.shape[1])
        if 'layer' in node and 'filter_idx' in node:
            print(node['layer'], node['filter_idx'])
            actmax = self._make_actmax(
                x,
                model,
                node['layer'],
                node['filter_idx']
            )
            return Payload(actmax, PayloadType.IMAGE)
        return Payload(None, None)