Multi-modal models and optional inputs #4293
Replies: 1 comment 3 replies
-
|
Hey! There is no official example yet on modeling multiple modalities, but your data points (i.e., dataset item which are combined into batches) and module inputs can simply be represented with an An example module: #[derive(Module, Debug)]
pub struct MultiModalModel<B: Backend> {
optional_1: Option<Linear<B>>,
optional_2: Option<Linear<B>>,
concat: Linear<B>,
}though in your case I think the submodules are not necessarily optional, just the computation based on the impl<B: Backend> MultiModalModel<B> {
pub fn forward(
&self,
image: Option<Tensor<B, 4>>,
spectral: Option<Tensor<B, 3>>,
// etc.
) -> Tensor<B, 2> {
if let Some(image) = image {
// Compute for image
}
if let Some(spectral) = spectral {
// Compute for spectral
}
}
}For the data, you can represent each item type with multiple Lmk if I missed anything from the original question. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Hi,
I have recently started to look into burn as a viable high-level crate to use in my lab instead of writing our own kernels, but I might be having some vocabulary difficulties in finding the aforementioned basic features in the documentation of the library.
Most datasets we work on are characterized by having variable features for variable datapoints (e.g. some have images, some have text, some have spectral properties, some have any combination of the above). We use the rather trivial approach to dispatch any feature set to the appropriate input submodule and then use a concatenation/dense layer on top, avoiding any computation/backprop for the unuset modules.
How are multi-modality & optional input features handled in burn? Are there examples somewhere?
Best,
Luca
Beta Was this translation helpful? Give feedback.
All reactions