Skip to main content
. 2021 May 26;21(11):3708. doi: 10.3390/s21113708
Algorithm 1 Implementation of the ConvCNPs–SDE model
Inputs: ID dataset pID(x,y); CR and MR are the context rate and missing rate, respectively; ccnps represents the ConvCNPs model of vNPs for completing the ID dataset; h1 is the downsampling net for 2D image classification tasks or the upsampling net for 1D regression tasks; h2 is the fully connected net; f represents the drift net and g represents the diffusion net; t is the layer depth; L1 is the cross-entropy loss function, L2 is the log-likelihood loss function, and L3 is the binary cross-entropy loss function.
Outputs: Means and Vars
for #training iterations do
1. Sample a minibatch of m data: (Xm,Ym) ~ pID(x,y);
2. if for 1D regression task:
3. Context points (Xcm,Ycm) are generated from sampled target points (Xtm,Ytm) based on CR, where (Xtm,Ytm) equals (Xm,Ym);
4. Forward through the ConvCNPs model: Y_dist = ccnps(Xcm,Ycm,Xtm);
5. Forward through the upsampling net of the SDE-Net block: X0m=h1(Xm,Ym);
6. else for 2D image classification task:
7. Forward through the ConvCNPs model: Y_dist = ccnps(Xm,Ym);
8. Forward through the downsampling net of the SDE-Net block: X0m=h1(Xm,Ym);
9. for k = 0 to t − 1 do
10. Sample Zkm~N(0,1);
Xk+1m=Xkm+f (Xkm,t)t+g(X0m)tZk;
11. end for
12. Forward through the fully connected layer of the SDE-Net block: Yfm=h2(Xkm);
13. Update h1, h2 and f by  h1, h2 and f 1mL1(Yfm,Ym);
14. Update ccnps by ccnps 1mL2(Y_dist.means,Ytm);
15. Sample a minibatch of m data from ID: (Xm,0)~pID(x,y);
16. Sample a minibatch of m data from OOD: (X˜m,1)~pOOD(x,y);
17. Forward through the downsampling or upsampling nets of the SDE-Net block: X0m,X˜0m=h1(Xm),h1(X˜m);
18. Update g by g1mL3(g(X0m),0)gL3(g(X˜0m),1);
for #testing iterations do
19. Evaluate the of ConvCNPs–SDE model;
20. Sample a minibatch of m data from ID: (Xm,Ym)~ pID(x,y);
21. mask = Bernoulli (1-MR)
22. masked_Xm = maskXm;
23. completed_Xm= ccnps(masked_Xm);
24. Means, Vars = SDE-Net(completed_Xm);