Modify the Fusion Models
The fusion models in fusilli
can be customized by passing a dictionary of attributes into the fusilli.data.prepare_fusion_data()
and fusilli.train.train_and_save_models()
functions.
Examples of how to modify the models can be found in the Customising Fusilli section.
Below are the modifiable attributes with guidance on how they can be changed:
Note
If modifications are made to certain layers like mod1_layers
or img_layers
, the attribute fused_layers
will be updated to ensure the first layer has the correct input features corresponding to the modified layers. Similarly, altering fused_layers
will adjust the final_prediction layer’s input features accordingly.
Warning
Errors may occur if the input features of certain layer groups (e.g., mod1_layers
and img_layers
) are incorrect. For instance, changing mod1_layers
input features to 20 while the actual number for the first tabular modality is 10 will result in a matrix multiplication error during the forward method.
Warning
If you’re using external test data, don’t forget to pass the layer modifications into your evaluation figure function (like fusilli.eval.RealsVsPreds.from_new_data()
).
Constructing the Layer Modification Dictionary
To construct the dictionary:
First keys should be the methods mentioned below.
Second keys should be the attributes from the tables below.
Value is the intended modification for the attribute.
For instance, modifying models using the “all” key applies those changes to all fusion models unless specifically overridden by a modification to a specific fusion model. Here’s an example demonstrating this:
layer_modifications = {
"all": {
"mod1_layers": nn.ModuleDict(
{
"layer 1": nn.Sequential(
nn.Linear(20, 32),
nn.ReLU(),
),
# ... (additional layer modifications)
}
),
}, # end of "all" key
"ConcatImgMapsTabularMaps": { # overrides modifications made to "all"
"mod1_layers": nn.ModuleDict(
{
"layer 1": nn.Sequential(
nn.Linear(20, 100),
nn.ReLU(),
),
# ... (additional layer modifications)
}
),
},
# ... (additional fusion model modifications)
}
Modifiable Attributes
ActivationFusion
Attribute |
Guidance |
---|---|
|
|
|
|
|
AttentionAndSelfActivation
Attribute |
Guidance |
---|---|
|
|
|
|
|
|
int |
AttentionWeightedGNN
Attribute |
Guidance |
---|---|
|
|
|
Float between (not including) 0 and 1. |
AttentionWeightedGraphMaker
Attribute |
Guidance |
---|---|
|
|
Integer between 0 and 100. |
|
Float between 0 and 1. |
|
|
|
|
|
ConcatImgLatentTabDoubleLoss
Attribute |
Guidance |
---|---|
int |
|
|
|
|
|
Loss function e.g. |
|
|
ConcatImgLatentTabDoubleTrain
Attribute |
Guidance |
---|---|
|
concat_img_latent_tab_subspace_method
Attribute |
Guidance |
---|---|
|
int |
|
|
|
|
ConcatImageMapsTabularData
Attribute |
Guidance |
---|---|
|
|
|
ConcatImageMapsTabularMaps
Attribute |
Guidance |
---|---|
|
|
|
|
|
ConcatTabularData
Attribute |
Guidance |
---|---|
|
ConcatTabularFeatureMaps
Attribute |
Guidance |
---|---|
|
|
|
|
|
CrossmodalMultiheadAttention
Attribute |
Guidance |
---|---|
int |
|
|
|
|
DAETabImgMaps
Attribute |
Guidance |
---|---|
|
denoising_autoencoder_subspace_method
Attribute |
Guidance |
---|---|
|
int |
|
|
|
|
|
|
|
|
EdgeCorrGNN
Attribute |
Guidance |
---|---|
|
|
Float between (not including) 0 and 1. |
EdgeCorrGraphMaker
Attribute |
Guidance |
---|---|
Float between (not including) 0 and 1. |
ImageChannelWiseMultiAttention
Attribute |
Guidance |
---|---|
|
|
|
|
|
ImageDecision
Attribute |
Guidance |
---|---|
|
|
|
|
Function (such as mean, median, etc.). Should act on the 1st dimension. |
ImgUnimodal
Attribute |
Guidance |
---|---|
|
|
|
MCVAE_tab
Attribute |
Guidance |
---|---|
|
|
|
MCVAESubspaceMethod
Attribute |
Guidance |
---|---|
int |
|
int |
|
int |
TabularCrossmodalMultiheadAttention
Attribute |
Guidance |
---|---|
int |
|
|
|
|
Tabular1Unimodal
Attribute |
Guidance |
---|---|
|
|
|
Tabular2Unimodal
Attribute |
Guidance |
---|---|
|
|
|
TabularChannelWiseMultiAttention
Attribute |
Guidance |
---|---|
|
|
|
|
|
TabularDecision
Attribute |
Guidance |
---|---|
|
|
|
|
Function (such as mean, median, etc.). Should act on the 1st dimension. |