SlowGuess/NeurIPS_2023_OCR huggingface dataset:
- NP2.4: Each NP2.4 probe consists of four shanks and a total of 384 channels (Steinmetz et al., 2021). NP2.4 probes are more dense (i.e., more channels in a given area) than NP1. The mice were trained in accordance with the IBL experiment protocols to perform a visual decision-making task. The behavioral correlates we decode are choice, motion energy, and wheel speed.
- NP1-NHP: NP1-NHP is designed for nonhuman primate species, such as macaques. The NP1-NHP probe maintains the same number of channels as NP1 (384), but its overall length is extended, resulting in a sparser configuration compared to NP1 (Trautmann et al., 2023). During the experiment, the macaque underwent training in a sequential multi-target reaching task (Marshall et al., 2022). The behavioral correlate we decode is the monkey's arm force. The probe was implanted in the macaque's motor cortex.
Comparison to a state-of-the-art clusterless decoder. Although the lack of available code for prior methods make comprehensive comparisons difficult, we benchmark our density-based decoder against a state-of-the-art clusterless decoder on datasets from both HD probes and multiple tetrodes. We compare our method to the clusterless point process decoder of Denovellis et al. (2021), which utilizes a marked point process to connect spike features with behaviors. For more details of this comparison, see Section 9 of the supplementary materials.
To decode the binary choice variable, we utilize the CAVI algorithm described in Supplement 2. For continuous behaviors like motion energy, wheel speed, and arm force, we employ the ADVI algorithm outlined in Supplement 1. We specify the maximum number of iterations as a hyperparameter in the CAVI model as it requires analytical updates for the model parameters. Running the CAVI encoder and decoder for fewer than 50 iterations yields satisfactory decoding outcomes. As for the ADVI algorithm, we implement it in PyTorch and update the model parameters using the Adam optimizer with a learning rate of 0.001 and a batch size of 6. The ADVI model is run for 1000 iterations. Open source code is available at https://github.com/yzhang511/density_decoding.
Varying levels of spike sorting quality. The performance of our method in comparison to the spike-thresholded and spike-sorted decoders for both the "good" and "bad" sorting examples is summarized in Figure 2. For the "good" sorting examples, our method has the highest decoding performance for motion energy and wheel speed. For choice decoding, our approach is comparable to decoding based on all KS single-units and better than decoders based on multi-unit thresholding and "good" KS units. For the "bad" sorting sessions, the gap in decoding performance between our method and other decoders is more pronounced. Example traces are illustrated in Figure 2 (c), which demonstrate that the behavior traces decoded by our method closely match the observed traces compared to decoded traces from the sorted decoders. In Figure 2 (d), we quantify the relationship between sorting quality and decoding quality using data from 20 IBL sessions. For all three quality metrics, the performance of our decoder and the spike-sorted decoder decreases as the quality of the sorting decreases. Despite this decrease in performance, our method consistently has better performance than the spike-sorted decoder even in the presence of significant motion drift as well as a when there is a large fraction of missed spikes or contaminated units.
Figure 3: Decoding comparisons broken down by brain regions. (a) We decoded 20 IBL datasets acquired using NP1 probes which were inserted into mice performing a behavioral task. The locations of the probe insertions in the mouse brain and the corresponding brain parcellations along the NP1 probe are shown. We compared the performance of all decoders across different recorded brain regions. For the "All" region, spikes from all brain regions were utilized for decoding. In contrast, for the "PO," "LP," "DG," "CA1," and "VISA" regions, only spikes from the respective regions were used for decoding. The decoding performance were summarized using box plots showing metrics obtained through a 5-fold CV and averaged across 20 IBL sessions. We observe a higher accuracy from PO, LP, and VISA regions when decoding choice; decoding results are more comparable across regions for the continuous behavioral variables. Our proposed decoder consistently achieves higher accuracy in decoding the continuous variables. (b) We use scatter plots to quantify the relationship between decoding quality, measured by  $R^2$  from decoding motion energy, and the number of components used for decoding. In the case of "all KS" and "good KS", the number of components corresponds to the number of KS units. For our method, the number of components refers to the number of MoG components used. For all methods, the decoding performance is higher when using more components (in the regime of a small number of components). Our decoding method consistently outperforms spike-sorted decoders based on KS 2.5 while tending to need fewer components.
Figure 4: Decoding performance generalizes across different animals and probe geometry. (a) We compare all decoders on a NP2.4 dataset using box plots showing performance metrics obtained from a 5-fold CV. Our method achieves much higher performance than all other decoders on continuous behavior decoding with slightly worse choice decoding than the spike-sorted decoder. (b) We utilize data from a single NP1-NHP recording session to decode the reaching force of a monkey engaged in a path-tracking (pacman) behavioral task. The decoders are evaluated through both quantitative analysis (box plots) and qualitative examination of the decoded traces. Each trial within the NP1-NHP recording has a duration of 9.85 seconds. Our method outperforms all other decoders on predicting the arm force.
Different brain regions from 20 datasets. The decoding results across various brain regions for 20 IBL sessions are summarized in Figure 3. Overall, our approach consistently achieves higher  $R^2$  values compared to other competing methods in decoding both motion energy and wheel speed across the five recorded brain regions. Notably, decoders based on "good" KS units exhibit poor performance across all recorded brain regions when compared to decoders based on all KS units. This observation highlights the importance of utilizing all available information for decoding behaviors rather than solely relying on "good" units based on sorting quality metrics. The scatter plots in Figure 3 (b) indicate a general trend where decoding quality tends to increase when more components (i.e., KS units for the spike-sorted decoders and MoG components for our method) are available for decoding. However, our method outperforms spike-sorted decoders even with a limited number of components.
Different probe geometry. The decoding results for the NP2.4 and NP1-NHP geometries are illustrated in Figure 4. For NP2.4, our approach significantly outperforms other competing methods when decoding motion energy and wheel speed, while again, the approaches are more comparable when decoding the discrete choice variable (our method performs slightly worse than the spike-sorted decoder). For NP1-NHP, Figure 4 demonstrates that our method achieves better decoding performance  $(R^2 \approx 0.6)$  compared to the spike-thresholded  $(R^2 \approx 0.2)$  and spike-sorted baselines  $(R^2 \approx 0.3)$ . "Good" KS units are not available in this scenario (the IBL quality criteria were not applied to this primate dataset) and are therefore not included in the results.
Comparison to a state-of-the-art clusterless decoder. We compare our method to a state-of-the-art clusterless point process decoder (Denovellis et al., 2021) in Table 1. Our method has higher decoding performance than the point process decoder on both HD and simulated tetrode datasets for all behavior variables. This performance improvement is likely due to the increased flexibility of our decoder compared to state-space models that make stronger assumptions about the dynamics of the decoded signals.
Computation time. In Figure 5, we provide a computation time comparison relative to real-time. Our decoding step operates at a sub-real-time pace (0.3 times real-time). The total time after preprocessing for our method is close to real-time.
Multiple tetrodes (position)	NP1 (wheel speed)	NP1 (motion energy)
Denovellis et al. (2021)	0.91 (± 0.01)	0.50 (± 0.16)	0.55 (± 0.15)
Density-Based	0.97 (± 0.03)	0.63 (± 0.12)	0.63 (± 0.14)
Table 1: Comparison to a state-of-the-art clusterless decoder. We evaluated the performance of both methods using 5-fold cross-validation. We reported the mean correlation between the ground-truth behavior and the decoded behavior along with the standard deviation. All tetrode data was simulated. For the HD datasets, we averaged the results across three IBL datasets.
Figure 5: Computation time measured relative to real-time. "Preprocessing" includes destriping, required by all decoders (IBL et al., 2022). "Total after preprocess" includes spike subtraction, denoising, localization, registration and density-decoding. The computation time of the clusterless point process decoder (Denovellis et al., 2021) is also provided.
In this work, we introduce a probabilistic model-based neural decoding method that relates spike feature distributions to behavioral correlates for more accurate behavior decoding. Our method is designed for high-density recording devices such as Neuropixels probes, utilizing novel HD spike features (i.e., spike locations) and maximum peak-to-peak amplitudes of the spikes. We further develop an efficient variational approach to perform inference in this model. We benchmark our method across a comprehensive set of HD recordings with varying levels of sorting quality, different probe geometries, and distinct brain regions. We demonstrate that our decoding method can consistently outperform spike-thresholded decoders and spike-sorted decoders across a wide variety of experimental contexts. This motivates a shift towards a spike-feature based decoding paradigm that avoids the need for spike sorting while also achieving comparable or superior decoding performance to approaches relying on well-isolated single-units.
While our method shows promising results, it is essential to explore avenues for improvement. Two potential improvements to our method include utilizing deep learning-based models to capture complex functional associations between firing rates and behaviors and also introducing dependencies among the mixture components to account for correlated neuronal firing patterns. An interesting extension of this work would be to apply this spike-feature based paradigm to unsupervised learning of neural dynamics which would enable us to estimate MoG "firing rates" conditioned on time-varying latent variables. By addressing these challenges and expanding the scope of our method, we can advance our understanding of neural activity and its relationship with behavior in both the supervised and unsupervised settings.
Neuroscience research aims to uncover how much behavior information can be decoded from neural signals in specific brain regions. To do this fairly across regions without bias from spike sorting quality, we need decoding methods that do not rely on spike sorting. However, we should recognize the current decoders' limitations to avoid drawing erroneous conclusions from the decoding results. Our generative model, which improves predictive performance by conditioning on external variables, is also relevant to the machine learning community.
This work was supported by grants from the Wellcome Trust (209558 and 216324), National Institutes of Health (1U19NS123716 and K99MH128772) and the Simons Foundation. We thank Matt Whiteway, Tatiana Engel, and Alexandre Pouget for helpful conversations and feedback on the manuscript.
Anne E Urai, Brent Doiron, Andrew M Leifer, and Anne K Churchland. Large-scale neural recordings call for new insights to link brain and behavior. Nature neuroscience, 25(1):11-19, 2022.
Valérie Ventura. Spike train decoding without spike sorting. Neural computation, 20(4):923-963, 2008.
Valérie Ventura. Traditional waveform based spike sorting yields biased rate code estimates. Proceedings of the National Academy of Sciences, 106(17):6921-6926, 2009.
Charlie Windolf, Angelique C Paulk, Yoav Kfir, Eric Trautmann, Samuel Garcia, Domokos Meszena, William Muñoz, Richard Hardstone, Irene Caprara, Mohsen Jamali, et al. Robust online multiband drift estimation in electrophysiology data. bioRxiv, pages 2022-12, 2022.
1 Decoding using automatic differentiation variational inference (ADVI)
In the method section of our paper, we describe the general encoding-decoding paradigm. In this section of the supplementary material, we delve into a specific case that focuses on decoding continuous behaviors,  $y_{k} \in \mathbb{R}^{T}$ , that exhibit temporal variations. We introduce the use of ADVI, which allows us to model the relationship between firing rates of MoG components and behavior correlates using a generalized linear model (GLM).
Notation	Definition
s_itk	spike feature i at time bin t in trial k
yk	behavior in trial k
z_itk	MoG assignment of spike feature i at time bin t in trial k
ηc = (μc, Σc)	mean and covariance matrix of MoG component c
πtk	MoG mixing proportion at time bin t in trial k
ntk	number of spikes collected at time bin t in trial k
C	number of MoG components
T	number of time bins within each trial
K	number of trials in a session
ADVI	λctk	behavior-dependent firing rate of component c at time bin t in trial k
bc	“baseline firing rate” of component c
βct	“behavior-modulated firing rate” of component c at time bin t
ηbc = (μbc, σ2bc)	mean and variance of the variational posterior distribution for bc
ηβct = (μβct, σ2βct)	mean and variance of the variational posterior distribution for βct
ηytk = (μytk, σ2ytk)	mean and variance of the variational posterior distribution for ytk
CAVI	λct1, λct0	firing rate of component c at time bin t that switches between two states
φ	variational parameter that represents the probability of yk = 1
ρictk	unnormized posterior probability of assigning s_itk to component c
rictk	normalized posterior probability of assigning s_itk to component c
yk1*, yk0*	unnormized posterior probability of yk = 1 and yk = 0
νk	normalized posterior probability of yk = 1
Table 2: Table of notation.
1.1 ADVI-based encoder
Building upon the general model specification outlined in Equations 1-3, we can describe the generative model of the encoder as follows:
$$
\lambda_ {c t k} = \exp \left(b _ {c} + \beta_ {c t} \cdot y _ {t k}\right), b _ {c} \sim \mathcal {N} \left(b _ {c}; 0, 1\right), \beta_ {c t} \sim \mathcal {N} \left(\beta_ {c t}; 0, 1\right), \tag {6}
$$
$$
z _ {i t k} \sim \text {C a t e g o r i c a l} \left(z _ {i t k}; \pi_ {t k}\right), \pi_ {t k} = \left\{\pi_ {c t k} \right\} _ {c = 1} ^ {C}, \pi_ {c t k} = \frac {\lambda_ {c t k}}{\sum_ {c ^ {\prime}} \lambda_ {c ^ {\prime} t k}}, \tag {7}
$$
$$
s _ {i t k} \sim \mathcal {N} \left(s _ {i t k}; \eta_ {z _ {i t k}}\right), \eta_ {c} = \left(\mu_ {c}, \Sigma_ {c}\right), \tag {8}
$$
where  $b$  and  $\beta$  are the unknown model parameters corresponding to  $\theta$  in Equation 1, and are sampled from a standard normal prior distribution. The latent spike assignment  $z$  depends on the mixing proportion  $\pi$  of the MoG, which is influenced by the behavior  $y$  through the firing rate  $\lambda$ . Intuitively, we can interpret  $\lambda_{ctk}$  as the "firing rate" of component  $c$  at time  $t$  in trial  $k$ , while  $b_{c}$  and  $\beta_{c}$  describe the "baseline firing rate" and "behavior-modulated firing rate" of component  $c$ , respectively.
To learn the latent variables  $z$ ,  $b$  and  $\beta$ , we posit a mean-field Gaussian variational approximation
$$
q (z, b, \beta) = \prod_ {c, t} q \left(z _ {c t}\right) q \left(b _ {c}\right) q \left(\beta_ {c t}\right) \tag {9}
$$
for the posterior distribution  $p(z, b, \beta \mid s, y)$ . Obtaining exact updates for  $b$  and  $\beta$  is challenging due to the normalization term for  $\pi$  in Equation 7. Therefore, we employ ADVI to maximize the
ELBO and utilize stochastic gradient ascent to update  $b$  and  $\beta$ . ADVI requires that the model be differentiable with respect to the parameters, and with a normal prior, the latent variables  $b$  and  $\beta$  reside in the real coordinate space and cause no issues with differentiability. The variational approximations for  $b$  and  $\beta$  are
$$
q (b) = \prod_ {c} q \left(b _ {c}; \eta_ {b _ {c}}\right) = \prod_ {c} \mathcal {N} \left(b _ {c}; \eta_ {b _ {c}}\right), \eta_ {b _ {c}} = \left(\mu_ {b _ {c}}, \sigma_ {b _ {c}} ^ {2}\right), \tag {10}
$$
$$
q (\beta) = \prod_ {c, t} q \left(\beta_ {c t}; \eta_ {\beta_ {c t}}\right) = \prod_ {c, t} \mathcal {N} \left(\beta_ {c t}; \eta_ {\beta_ {c t}}\right), \eta_ {\beta_ {c t}} = \left(\mu_ {\beta_ {c t}}, \sigma_ {\beta_ {c t}} ^ {2}\right). \tag {11}
$$
A drawback of the parameterization in Equations 6-8 is that the spike assignment variables  $z$  are discrete and not compatible with ADVI. An alternative, equivalent parameterization that addresses these problems is to marginalize over  $z$ . The marginalized model is
$$
\lambda_ {c t k} = \exp \left(b _ {c} + \beta_ {c t} \cdot y _ {t k}\right), b _ {c} \sim \mathcal {N} \left(b _ {c}; 0, 1\right), \beta_ {c t} \sim \mathcal {N} \left(\beta_ {c t}; 0, 1\right), \tag {12}
$$
$$
\pi_ {c t k} = \frac {\lambda_ {c t k}}{\sum_ {c ^ {\prime}} \lambda_ {c ^ {\prime} t k}}, \pi_ {t k} = \left\{\pi_ {c t k} \right\} _ {c = 1} ^ {C}, \tag {13}
$$
$$
s _ {i t k} = \sum_ {c = 1} ^ {C} \pi_ {c t k} \mathcal {N} \left(s _ {i t k}; \eta_ {c}\right), \eta_ {c} = \left(\mu_ {c}, \Sigma_ {c}\right). \tag {14}
$$
Under this parameterization, the ELBO for the encoder is
$$
\begin{array}{l} \mathcal {L} _ {\mathrm {e n c}} ^ {\mathrm {A D V I}} := \mathbb {E} _ {q (b, \beta)} [ \log p (s, b, \beta \mid y) ] - \mathbb {E} _ {q (b, \beta)} [ \log q (b, \beta) ] (15) \\ = \mathbb {E} _ {q (b, \beta)} \left[ \sum_ {k, t, c, i} \log \mathcal {N} \left(s _ {i t k}; \eta_ {c}\right) + \log \pi_ {c t k} + \log \mathcal {N} \left(b _ {c}; 0, 1\right) + \log \mathcal {N} \left(\beta_ {c t}; 0, 1\right) \right] (16) \\ - \mathbb {E} _ {q (b, \beta)} \left[ \sum_ {c, t} \log \mathcal {N} \left(b _ {c}; \eta_ {b _ {c}}\right) + \log \mathcal {N} \left(\beta_ {c t}; \eta_ {\beta_ {c t}}\right) \right]. \\ \end{array}
$$
1.2 ADVI-based decoder
The decoder adopts the same generative model as the encoder described in Equations 6-8 with two exceptions: 1) The latent variable  $y_{tk}$  is assumed to have a standard normal prior, i.e.,  $y_{tk} \sim \mathcal{N}(y_{tk};0,1)$ , assuming independence at each time step  $t$ . Alternatively, a Gaussian process prior can be chosen to capture temporal correlations between time steps. 2) The parameters  $b$  and  $\beta$  are learned from the ADVI-based encoder and kept fixed in the decoder.
The mean-field Gaussian variational approximation for the posterior distribution  $p(z, y \mid s)$  is
$$
q (z, y) = \prod_ {c, t} q \left(z _ {c t}\right) q \left(y _ {t}\right), \tag {17}
$$
$$
q (y) = \prod_ {k, t} q \left(y _ {t k}; \eta_ {y _ {t k}}\right) = \prod_ {k, t} \mathcal {N} \left(y _ {t k}; \eta_ {y _ {t k}}\right), \eta_ {y _ {t k}} = \left(\mu_ {y _ {t k}}, \sigma_ {y _ {t k}} ^ {2}\right). \tag {18}
$$
To enable the use of ADVI, we can marginalize out the discrete latent variable  $z$ , thereby transforming the MoG model into a differentiable form. Under the marginalized MoG parametrization in Equations 12-14, the ELBO of the decoder is
$$
\begin{array}{l} \mathcal {L} _ {\mathrm {d e c}} ^ {\mathrm {A D V I}} := \mathbb {E} _ {q (y)} [ \log p (s, y) ] - \mathbb {E} _ {q (y)} [ \log q (y) ] (19) \\ = \mathbb {E} _ {q (y)} \left[ \sum_ {k, t, c, i} \log \mathcal {N} \left(s _ {i t k}; \eta_ {c}\right) + \log \pi_ {c t k} + \log \mathcal {N} \left(y _ {t k}; 0, 1\right) \right] (20) \\ - \mathbb {E} _ {q (y)} \left[ \sum_ {k, t} \log \mathcal {N} \left(y _ {t k}; \eta_ {y _ {t k}}\right) \right]. \\ \end{array}
$$
2 Decoding using coordinate ascent variational inference (CAVI)
We present a specific scenario for decoding binary variables,  $y_{k} \in \{0,1\}$ , where we derive exact updates for the variational variables using CAVI.
2.1 CAVI-based encoder
Extending the general model described in Equations 1-3, the generative model of the encoder can be defined as follows:
$$
\pi_ {c t k} = \left(\frac {\lambda_ {c t 1}}{\sum_ {c ^ {\prime}} \lambda_ {c ^ {\prime} t 1}}\right) ^ {y _ {k}} \left(\frac {\lambda_ {c t 0}}{\sum_ {c ^ {\prime}} \lambda_ {c ^ {\prime} t 0}}\right) ^ {1 - y _ {k}}, \tag {21}
$$
$$
z _ {i t k} \sim \text {C a t e g o r i c a l} \left(z _ {i t k}; \pi_ {t k}\right), \pi_ {t k} = \left\{\pi_ {c t k} \right\} _ {c = 1} ^ {C}, \tag {22}
$$
$$
s _ {i t k} \sim \mathcal {N} \left(s _ {i t k}; \eta_ {z _ {i t k}}\right), \eta_ {c} = \left(\mu_ {c}, \Sigma_ {c}\right), \tag {23}
$$
where  $z$  and  $\lambda$  are the latent variables that we aim to learn. The behavior-dependent firing rates of each component  $c$  at time  $t$  vary based on the binary variable  $y$ , such that the components switch between two behavioral states characterized by firing rates  $\lambda_{ct1}$  and  $\lambda_{ct0}$ .
The log-likelihood of the encoder can be written as
$$
\begin{array}{l} \log p (s, z \mid y) = \sum_ {k, t, c, i} z _ {i c t k} \left\{\log \mathcal {N} \left(s _ {i t k}; \eta_ {c}\right) + y _ {k} \left(\log \lambda_ {c t 1} - \log \Lambda_ {t 1}\right) \right. \tag {24} \\ \left. + \left(1 - y _ {k}\right) \left(\log \lambda_ {c t 0} - \log \Lambda_ {t 0}\right) \right\}, \\ \end{array}
$$
where  $\Lambda_{t1} = \sum_{c'}\lambda_{c't1}$  and  $\Lambda_{t0} = \sum_{c'}\lambda_{c't0}$ . To approximate the posterior  $p(z\mid s,y)$ , we employ the mean-field variational approximation  $q(z) = \prod_{c,t}q(z_{ct})$ . The ELBO of the encoder is
$$
\mathcal {L} _ {\text {e n c}} ^ {\text {C A V I}} := \mathbb {E} _ {q (z)} [ \log p (s, z \mid y) ] - \mathbb {E} _ {q (z)} [ \log q (z) ]. \tag {25}
$$
The exact update for  $q(z)$  is obtained by maximizing the ELBO with respect to  $q(z)$ , which leads to the following update equation:
$$
q \left(z _ {c t}\right) \propto \exp \left\{\mathbb {E} _ {q _ {- c t}} \left[ \log p \left(z _ {c t}, z _ {- c t}, s \mid y\right) \right] \right\}, \tag {26}
$$
where  $q_{-ct}$  means  $\prod_{c' \neq c} \prod_{t' \neq t} q(z_{c't'})$ . Then,
$$
q \left(z _ {i c t k} = 1\right) \propto \exp \left\{\log \mathcal {N} \left(s _ {i t k}; \eta_ {c}\right) + y _ {k} \log \left(\frac {\lambda_ {c t 1}}{\Lambda_ {t 1}}\right) + \left(1 - y _ {k}\right) \log \left(\frac {\lambda_ {c t 0}}{\Lambda_ {t 0}}\right) \right\} := \rho_ {i c t k} \tag {27}
$$
denotes the unnormalized posterior probability of assigning spike  $i$  collected at time  $t$  in trial  $k$  to component  $c$ , while  $\mathbb{E}[z_{ictk}] = \rho_{ictk} / \sum_{c'} \rho_{ic'tk} := r_{ictk}$  represents the normalized posterior probability.
After fixing  $q(z)$ , the term in the ELBO which depends on  $\lambda, \mu$  and  $\Sigma$  can be expressed as
$$
\mathcal {L} := \sum_ {k, t, c, i} r _ {i c t k} \big \{\log \mathcal {N} (s _ {i t k}; \eta_ {c}) + y _ {k} \log \left(\frac {\lambda_ {c t 1}}{\Lambda_ {t 1}}\right) + (1 - y _ {k}) \log \left(\frac {\lambda_ {c t 0}}{\Lambda_ {t 0}}\right) \big \}.
$$
Algorithm 1 CAVI-based encoder
Input: {s_itk}, {y_k}, i = 1: nt_k, t = 1: T, k = 1: K, number of components C.
Initialize {μc, Σc}, c = 1: C.
while ELBO not converged do
for all k ∈ 1: K do
for all t ∈ 1: T do
for all i ∈ 1: nt_k do
Set q(zictk = 1) ∝ ρictk.	▷ eq. (27)
end for
end for
end for
for all c ∈ 1: C do
Set μc = μc*, Σc = Σc.	▷ eq. (36-39)
for all t ∈ 1: T do
Set λct0 = λct0*, λct1 = λct1.	▷ eq. (32-33)
end for
end for
Compute the ELBO LencAVI.	▷ eq. (25)
end while
Return q(z), λ, μ, Σ.
We derive the update for  $\lambda$  by setting the gradients  $\nabla_{\lambda_{ct1}}\mathcal{L}$  and  $\nabla_{\lambda_{ct0}}\mathcal{L}$  to 0: