Optimize ensemble when Gram-Schmidt is not requested

This commit is contained in:
Nuwan Yapa 2025-01-30 13:08:13 -05:00
parent 3b2277cbd0
commit 37fa83a4e2
1 changed files with 11 additions and 4 deletions

9
EC.jl
View File

@ -58,10 +58,17 @@ function train!(EC::affine_EC, c_vals; ref_eval=-10.0, CAEC=false, gram_schmidt_
(EC.H0_EC, EC.H1_EC, EC.N_EC) = get_reduced_matrices(EC, training_vecs, gram_schmidt_threshold; verbose=true) (EC.H0_EC, EC.H1_EC, EC.N_EC) = get_reduced_matrices(EC, training_vecs, gram_schmidt_threshold; verbose=true)
for _ in 1:EC.ensemble_size for _ in 1:EC.ensemble_size
(H0_EC, H1_EC, N_EC) = get_reduced_matrices(EC, training_vecs, gram_schmidt_threshold, resample(length(training_vecs)); verbose=false) subsample = resample(length(training_vecs))
if gram_schmidt_threshold > 0
(H0_EC, H1_EC, N_EC) = get_reduced_matrices(EC, training_vecs, gram_schmidt_threshold, subsample; verbose=false)
push!(EC.H0_EC_ensemble, H0_EC) push!(EC.H0_EC_ensemble, H0_EC)
push!(EC.H1_EC_ensemble, H1_EC) push!(EC.H1_EC_ensemble, H1_EC)
push!(EC.N_EC_ensemble, N_EC) push!(EC.N_EC_ensemble, N_EC)
else
push!(EC.H0_EC_ensemble, EC.H0_EC[subsample, subsample])
push!(EC.H1_EC_ensemble, EC.H1_EC[subsample, subsample])
push!(EC.N_EC_ensemble, EC.N_EC[subsample, subsample])
end
end end
EC.trained = true EC.trained = true