Open hrlai opened 9 months ago
Thanks for this, @hrlai !
We are currently trying to debug an issue with cholesky, so hopefully this is related.
Here is the behaviour for an M1 mac running the TF2 branch (https://github.com/greta-dev/greta/tree/tf2-poke-tf-fun), and I'll post the output of the non M1 mac running TF1 soon.
It looks like you are using CRAN greta, so using TF2, correct?
So we don't get an error on M1 TF2 greta, but we get a bunch of NaN values, which is also undesirable.
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
greta_sitrep()
#> ℹ checking if python available
#> ✔ python (v3.8) available
#>
#> ℹ checking if TensorFlow available
#> ✔ TensorFlow (v2.11.0) available
#>
#> ℹ checking if TensorFlow Probability available
#> ✔ TensorFlow Probability (v0.19.0) available
#>
#> ℹ checking if greta conda environment available
#> ✔ greta conda environment available
#>
#> ℹ Initialising python and checking dependencies, this may take a moment.
#> ✔ Initialising python and checking dependencies ... done!
#>
#> ℹ greta is ready to use!
n <- 10
distance <- .7 ^ as.matrix(dist(1:n))
range <- exponential(1)
log_sd <- normal(0, 1)
Sigma <- exp(log_sd - 0.5 * (distance * range)^2)
L <- chol(Sigma)
Z <- normal(0, 1, n)
e <- t(t(Z) %*% L)
e
#> greta array (operation)
#>
#> [,1]
#> [1,] ?
#> [2,] ?
#> [3,] ?
#> [4,] ?
#> [5,] ?
#> [6,] ?
#> [7,] ?
#> [8,] ?
#> [9,] ?
#> [10,] ?
calculate(e, nsim = 1)
#> $e
#> , , 1
#>
#> [,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [,9] [,10]
#> [1,] NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN
Created on 2023-11-17 with reprex v2.0.2
Here is the behaviour with some simpler code using chol
on a non M1 mac using TF1 greta
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
greta_sitrep()
#> ℹ checking if python available
#> ✔ python (version 3.7) available
#>
#> ℹ checking if TensorFlow available
#> ✔ TensorFlow (version 1.14.0) available
#>
#> ℹ checking if TensorFlow Probability available
#> ✔ TensorFlow Probability (version 0.7.0) available
#>
#> ℹ checking if greta conda environment available
#> ✔ greta conda environment available
#>
#> ℹ Initialising python and checking dependencies, this may take a moment.
#> ✔ Initialising python and checking dependencies ... done!
#>
#> ℹ greta is ready to use!
x <- wishart(df = 4, Sigma = diag(3))
chol_x <- chol(x)
# debugonce(calculate)
calc_chol <- calculate(x, chol_x, nsim = 1)
#> Error in py_call_impl(callable, dots$args, dots$keywords): tensorflow.python.framework.errors_impl.InvalidArgumentError: You must feed a value for placeholder tensor 'Placeholder_1' with dtype double and shape [1,3,3]
#> [[node Placeholder_1 (defined at /ops/array_ops.py:2143) ]]
#>
#> Original stack trace for 'Placeholder_1':
#> File "/ops/array_ops.py", line 2143, in placeholder
#> return gen_array_ops.placeholder(dtype=dtype, shape=shape, name=name)
#> File "/ops/gen_array_ops.py", line 6262, in placeholder
#> "Placeholder", dtype=dtype, shape=shape, name=name)
#> File "/framework/op_def_library.py", line 788, in _apply_op_helper
#> op_def=op_def)
#> File "/util/deprecation.py", line 507, in new_func
#> return func(*args, **kwargs)
#> File "/framework/ops.py", line 3616, in create_op
#> op_def=op_def)
#> File "/framework/ops.py", line 2005, in __init__
#> self._traceback = tf_stack.extract_stack()
calc_chol
#> Error in eval(expr, envir, enclos): object 'calc_chol' not found
Created on 2023-11-17 by the reprex package (v2.0.1)
Hi there, facing
chol
failures on Windows. Decided to open a new thread in case this can be closed apart from the M1-related issues.I was trying to fit some spatial correlation structure but couldn't calculate.
mcmc
also complains about failing to find initial values, but I think maybe isolate this tocalculate
first, before testingmcmc
... Maybe I have simply mispecified the model.Created on 2023-10-19 with reprex v2.0.2