11using Test
22using HybridVariationalInference
33using HybridVariationalInference: HybridVariationalInference as CP
4+ using UnPack
45using StableRNGs
56using Random
67using Statistics
@@ -19,6 +20,7 @@ using Suppressor
1920
2021using Functors
2122
23+
2224cdev = cpu_device ()
2325
2426# scenario = Val((:default,))
106108 function test_f_doubleMM (θ:: AbstractVector{ET} , x; intθ1) where ET
107109 # extract parameters not depending on order, i.e whether they are in θP or θM
108110 θc = intθ1 (θ)
109- (r0, r1, K1, K2) = map ((:r0 , :r1 , :K1 , :K2 )) do par
110- CA. getdata (θc[par]):: ET
111- end
111+ @unpack r0, r1, K1, K2 = θc
112112 r0 .+ r1 .* x. S1 ./ (K1 .+ x. S1) .* x. S2 ./ (K2 .+ x. S2)
113113 end
114114 y = @inferred test_f_doubleMM (CA. getdata (θ2), xP1; intθ1 = int_θdoubleMM)
@@ -151,14 +151,16 @@ test_without_flux = (scenario) -> begin
151151 intϕ = ComponentArrayInterpreter (CA. ComponentVector (
152152 ϕg= 1 : length (ϕg0), ϕP= par_templates. θP))
153153 priors = get_hybridproblem_priors (prob; scenario)
154- priorsP = [ priors[k] for k in keys (par_templates. θP)]
155- priorsM = [ priors[k] for k in keys (par_templates. θM)]
154+ priorsP = Tuple ( priors[k] for k in keys (par_templates. θP))
155+ priorsM = Tuple ( priors[k] for k in keys (par_templates. θM))
156156 # slightly disturb θP_true
157157 p = p0 = vcat (ϕg0, par_templates. θP .* convert (eltype (ϕg0), 0.8 ))
158158
159159 # Pass the site-data for the batches as separate vectors wrapped in a tuple
160+ zero_prior_logdensity = CP. get_zero_prior_logdensity (
161+ priorsP, priorsM, par_templates. θP, par_templates. θM)
160162 loss_gf = get_loss_gf (g, transM, transP, f, py, intϕ;
161- pbm_covars, n_site_batch = n_batch, priorsP, priorsM,
163+ pbm_covars, n_site_batch = n_batch, priorsP, priorsM, zero_prior_logdensity,
162164 )
163165 (_xM, _xP, _y_o, _y_unc, _i_sites) = first (train_loader)
164166 # l1 = loss_gf(p0, _xM, _xP, _y_o, _y_unc, _i_sites; is_testmode = false)
@@ -312,13 +314,13 @@ test_with_flux_gpu = (scenario) -> begin
312314 (; y, θsP, θsMs) = predict_hvi (rng, probo; scenario = scenf, n_sample_pred);
313315 # to inspect correlations among θP and θMs construct ComponentVector
314316 # TODO redo get_int_PMst_site
315- # get_ca_int_PMs = let
316- # function get_ca_int_PMs_inner(n_site)
317- # ComponentArrayInterpreter(CA.ComponentVector(; P = θP,
318- # Ms = CA.ComponentMatrix(
319- # zeros(n_θM, n_site), first(CA.getaxes(θM)), CA.Shaped1DAxis((n_site,)))))
320- # end
321- # end
317+ # get_ca_int_PMs = let
318+ # function get_ca_int_PMs_inner(n_site)
319+ # ComponentArrayInterpreter(CA.ComponentVector(; P = θP,
320+ # Ms = CA.ComponentMatrix(
321+ # zeros(n_θM, n_site), first(CA.getaxes(θM)), CA.Shaped1DAxis((n_site,)))))
322+ # end
323+ # end
322324 int_mPMs = stack_ca_int (Val ((n_sample_pred,)), get_int_PMst_site (hpints))
323325 θs = int_mPMs (CP. flatten_hybrid_pars (θsP, θsMs))
324326 mean_θ = CA. ComponentVector (vec (mean (CA. getdata (θs), dims= 1 )), last (CA. getaxes (θs)))
0 commit comments