Deep learning image classificaiton informed by expert attention
Project description
Expert-attention guided deep learning for medical images
Get Started
Use the trained model for inference
Pip install the PYPI distro:
pip install expert-informed-dl
Check out example.py for a simple example of how to use the trained model for inference.
When forwarding image through the network, use the argument collapse_attention_matrix=True
to get the attention matrix
to get the attention matrix averaged across all heads and keys for each query token.
y_pred, attention_matrix = model(image_data, collapse_attention_matrix=False)
Train model locally
Install requirements.txt
Download Pytorch matching with a CUDA version matching your GPU from here.
Run train.py
For example, if you have 32 * 32 patches,
the attention matrix will be of size (32 * 32 + 1) 1025. Plus one for the classificaiton token.
If you set collapse_attention_matrix=False
, the attention matrix will be
uncollapsed. The resulting attention matrix will be of shape (n_batch, n_heads, n_queries, n_keys). For example, if you have 32 * 32 patches,
one image and one head, the attention matrix will be of shape (1, 1, 1025, 1025).
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Hashes for expert_informed_dl-0.0.3.dev1.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 660fb87ba94bab56585e4588c1c04f53c8f8fb0e61f47b489302e96f91bc71d9 |
|
MD5 | 8cb5da0327d6512c90304795ab6822fe |
|
BLAKE2b-256 | 2c4962c89545314e0e2d9eecaae13a4fba635bddbdfd8a5a4fe5f9b27e66e8a8 |
Hashes for expert_informed_dl-0.0.3.dev1-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 70d86bbd6142d1b0b4eb5f05e7600c62cf865c09faca836b0baac1fb3823cc5f |
|
MD5 | 272a44ed9b55f1b59c20501fbe058c9f |
|
BLAKE2b-256 | 30cf4d61f1b789ed7a346ccfa88e4d0685bc0e3a04477efebcf0111acfb53c21 |