Skip to main content

No project description provided

Project description

Create Activation Graphs for TG-CNN Model

Tests

Produce graphs using the 3D CNN layers from the trained TG-CNN model. These graphs show which edges or timesteps are the most important during model prediction.

Activation mapping graphs for edges steps:

  • Get the patient 'graph'
  • Get the filter with the strongest differentiation of maximum activation
  • Do element-wise multiplication between the filter and the patient graph
  • Make the edges with zero activation grey
    • Where an edge is the x and y for each timestep.
    • A node is a new node even if the node has already been visited.
    • Nodes can be named e.g. r5_t1 (read code = 5, timestep = 1)
    • Use the element-wise ('activation') result to colour the edges red if the connection isn't zero.

Limitations:

  • This method requires there to be no overlap in the CNN windows.

The equations of how maximum activation is calculated is as follows:

To get the edge weights: For a given filter $f_{k}$, patient $p$, and time step $i$, the process can be summarised as:

  1. Extract the slice:

    $ W_{i}^{(p, k)} = G_{p}[i:i+F, :, :], $

    where $F$ is the size of the filter in the time dimension, $G_{p}$ as the input tensor for patient $p$, $f_{k}$ as the $k$-th filter, and $W_{i}^{(p, k)}$ is the slice of the tensor $G_{p}$ at time step $i$ with the same dimensions as the filter $f_{k}$.

  2. Apply the filter and sum the result:

    $ S_{i}^{(p, k)} = \sum (W_{i}^{(p, k)} \odot f_{k}), $

    where $\odot$ denotes element-wise multiplication.

  3. Apply the leaky ReLU activation function:

    $ A_{i}^{(p, k)} = leaky ReLU(S_{i}^{(p, k)}, \alpha), $

    where $\alpha$ is the leaky ReLU parameter.

  4. Compute the maximum activation value across all time steps:

    $ \text{max_activation_value}{p, k} = \max{i} (A_{i}^{(p, k)}) $

  5. Combine these into one formula:

    $ Max Activation Value_{p, k} = \max_{i} \left( leaky ReLU \left( \sum (G_{p}[i:i+F, :, :] \odot f_{k}), \alpha \right) \right) $

USAGE

See examples in create_graphs.ipynb for how to use this code.

ROADMAP

See the Issues in GitHub for a list of proposed features and known issues.

TESTING

Run tests by using pytest test_graphs/test_calculations.py in the top directory.

LICENSE

Unless stated otherwise, the codebase is released under the BSD Licence. This covers both the codebase and any sample code in the documentation.

See LICENCE for more information.

ACKNOWLEDGEMENTS

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

tgcnn_act_graph-0.2.tar.gz (11.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

tgcnn_act_graph-0.2-py3-none-any.whl (12.4 kB view details)

Uploaded Python 3

File details

Details for the file tgcnn_act_graph-0.2.tar.gz.

File metadata

  • Download URL: tgcnn_act_graph-0.2.tar.gz
  • Upload date:
  • Size: 11.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.0 CPython/3.8.19

File hashes

Hashes for tgcnn_act_graph-0.2.tar.gz
Algorithm Hash digest
SHA256 a573b5224fb863d28296e115fd9665b857065c1a2a556afd742fb19a9c2259e0
MD5 b7b7e445cd1aecc918530e12183527d6
BLAKE2b-256 25a400b08c5d4c9d8440e25e9f046c66392c43b0500ef084ff26c3bb2c502c9a

See more details on using hashes here.

File details

Details for the file tgcnn_act_graph-0.2-py3-none-any.whl.

File metadata

  • Download URL: tgcnn_act_graph-0.2-py3-none-any.whl
  • Upload date:
  • Size: 12.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.0 CPython/3.8.19

File hashes

Hashes for tgcnn_act_graph-0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 5cd4f300e48ac57e066ce43c6e9fc8293f20d057d75f4fabfeb47d5bc6ed2bf6
MD5 f616c88b1d33cd2bd8cea7b576cf8180
BLAKE2b-256 962a9a9b1f764af3a7a3dc8aa1bfef2efd8daf0f96818ec3fd4beb59d804341d

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page