-
Notifications
You must be signed in to change notification settings - Fork 63
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
TF2 change cholesky target #637
Merged
njtierney
merged 10 commits into
greta-dev:tf2-poke-tf-fun
from
njtierney:tf2-change-chol-target-583-4-5
Jul 26, 2024
Merged
TF2 change cholesky target #637
njtierney
merged 10 commits into
greta-dev:tf2-poke-tf-fun
from
njtierney:tf2-change-chol-target-583-4-5
Jul 26, 2024
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
, greta-dev#585. Change create_target function inside of wishart_distrbution and lkj_correlation to return `chol_greta_array` instead of `matrix_greta_array`. This is returning the `cholesky_variable()` instead of `chol2symm`.
- Remove tests that check for cholesky warnings. - Update snapshots to include an upper triangular matrix for cholesky factor of LJK/Wishart distributions
- Test if greta array is lower triangular - Test if greta array is square
…angular (zeroes in the upper). - Use new custom expectations. - Add some TODO notes. - update snapshots
Current implementation in #637 removes representation approach. This is not as good, but right now I am really struggling to unfurl this problem and I'd rather get something that works. Here's a demo/comparison between branches # In patch branch:
library(greta)
#>
#> Attaching package: 'greta'
#> The following objects are masked from 'package:stats':
#>
#> binomial, cov2cor, poisson
#> The following objects are masked from 'package:base':
#>
#> %*%, apply, backsolve, beta, chol2inv, colMeans, colSums, diag,
#> eigen, forwardsolve, gamma, identity, rowMeans, rowSums, sweep,
#> tapply
n <- 3e3
Sigma <- wishart(n + 1, diag(n))
#> ℹ Initialising python and checking dependencies, this may take a moment.
#> ✔ Initialising python and checking dependencies ... done!
#>
chol_Sigma <- chol(Sigma)
Sigma2 <- wishart(n + 1, diag(n))
Sigma2_node <- greta:::get_node(Sigma2)
Sigma2_node$representations$cholesky <- NULL
Sigma2 <- greta:::as.greta_array(Sigma2_node)
chol_Sigma2 <- chol(Sigma2)
greta:::has_representation(Sigma, "cholesky")
#> [1] FALSE
greta:::has_representation(Sigma2, "cholesky")
#> [1] FALSE
bm_patch <- bench::mark(
sigma_asis = calculate(chol_Sigma, nsim = 10),
sigma_altered = calculate(chol_Sigma2, nsim = 10),
check = FALSE
)
#> Warning: Some expressions had a GC in every iteration; so filtering is
#> disabled.
bm_patch
#> # A tibble: 2 × 6
#> expression min median `itr/sec` mem_alloc `gc/sec`
#> <bch:expr> <bch:tm> <bch:tm> <dbl> <bch:byt> <dbl>
#> 1 sigma_asis 14s 14s 0.0717 831MB 0.0717
#> 2 sigma_altered 12.7s 12.7s 0.0785 824MB 0 Created on 2024-07-25 with reprex v2.1.0
|
This was referenced Jul 25, 2024
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Addressing cholesky initialisation issue in #583, #584, #585.
Change create_target function inside of wishart_distrbution and lkj_correlation to return
chol_greta_array
instead ofmatrix_greta_array
. This is returning thecholesky_variable()
instead ofchol2symm
.