Releases: greta-dev/greta
greta 0.5.0
This version of greta uses Tensorflow 2.0.0, which comes with it a host of new very exciting features!
Optimizers
The latest interface to optimizers in tensorflow are now used, these changes are described.
gradient_descent
gainsmomentum
andnesterov
arguments, as described here in TF docsadagrad
gainsepsilon
argument- removes
momentum
optimizer, as this has been folded intogradient_descent
arguments - Adds
amsgrad
argument toadam
optimizer, as described in TF docs - Adds
adamax
optimiser, see TF docs - Adds
l2_shrinkage_regularization_strength
andbeta
arguments toftrl
optimiser. - adds
nadam
optimiser - see docs. - In
rms_prop
optimiser, changesdecay
parameter torho
, and addscentered
parameter - see docs
The following optimisers are removed, as they are no longer supported by Tensorflow:
powell()
cg()
newton_cg()
l_bfgs_b()
tnc()
cobyla()
slsqp()
Installation revamp
This release provides a few improvements to installation in greta. It should now provide more information about installation progress, and be more robust. The intention is, it should just work, and if it doesn't, it should fail gracefully with some useful advice on problem solving.
- Added option to restart R + run
library(greta)
after installation (#523). - Added installation deps object,
greta_deps_sepc()
to help simplify specifying package versions (#664). - Removed
method
andconda
arguments frominstall_greta_deps()
as they
were not used. - Removed
manual
argument ininstall_greta_deps()
. - Added default 5 minute timer to installation processes.
- Added
greta_deps_receipt()
to list the current main python packages installed (#668). - Added checking suite to ensure you are using valid versions of TF, TFP, and Python(#666).
- Added data
greta_deps_tf_tfp
(#666), which contains valid versions combinations of TF, TFP, and Python. - Remove
greta_nodes_install/conda_*()
options as #493 makes them defunct. - Added option to write to a single logfile with
greta_set_install_logfile()
, andwrite_greta_install_log()
, andopen_greta_install_log()
(#493). - Added
destroy_greta_deps()
function to remove miniconda and python conda environment. - Improved
write_greta_install_log()
andopen_greta_install_log()
to usetools::R_user_dir()
to always write to a file location.open_greta_install_log()
will open one found from an environment variable or go to the default location (#703).
New Print methods
- New print method for
greta_mcmc_list
. This means MCMC output will be shorter and more informative (#644). - greta arrays now have a print method that stops them from printing too many rows into the console. Similar to MCMC print method, you can control the print output with the
n
argument:print(object, n = <elements to print>)
(#644).
Minor
greta_sitrep()
now checks for installations of Python, TF, and TFP.- Slice sampler no longer needs precision = "single" to work.
- greta now depends on R 4.1.0, which was released May 2021, over 3 years ago.
- export
is.greta_array()
andis.greta_mcmc_list()
. restart
argument forinstall_greta_deps()
andreinstall_greta_deps()
to automatically restart R (#523).
Internals
- Internally we are replacing most of the error handling code as separate
check_*
functions. - Implemented
cli::cli_abort/warn/inform()
in place ofcli::format_error/warning/message()
+stop/warning/message(msg, call. = FALSE)
pattern. - Uses legacy optimizer internally (Use
tf$keras$optimizers$legacy$METHOD
overtf$keras$optimizers$METHOD
). No user impact expected. - Update photo of Grete Hermann (#598).
- Use
%||%
internally to replace the pattern:if (is.null(x)) x <- thing
withx <- x %||% thing
(#630). - Add more explaining variables - replace
if (thing & thing & what == this)
withif (explanation_of_thing)
. - Refactored repeated uses of
vapply
into functions (#377, #658). - Add internal data files
.deps_tf
and.deps_tfp
to track dependencies of TF and TFP. Related to #666.
- Posterior density checks (#720):
- Don't run Geweke on CI as it takes 30 minutes to run.
- Add thinning to Geweke tests.
- Fix broken geweke tests from TF1-->TF2 change.
- Increase the number of effective samples for check_samples for lkj distribution
- Add more checks to posterior to run on CI/on each test of greta
Bug fixes
- Fix bug where matrix multiply had dimension error before coercing to greta array. (#464)
- Fixes for Wishart and LKJ Correlation distributions (#729 #733 #734):
- Add bijection density to choleskied distributions.
- Note about some issues with LKJ and our normalisation constant for the density.
- Removed our custom
forward_log_det_jacobian()
function fromtf_correlation_cholesky_bijector()
(used inlkj_correlation()
). Previously, it did not work with unknown dimensions, but it now works with them. - Ensure wishart uses sigma_chol in scale_tril
- Wishart uses
tf$matmul(chol_draws, chol_draws, adjoint_b = TRUE)
instead oftf_chol2symm(chol_draws)
. - Test log prob function returns valid numeric numbers.
- Addresses issue with log prob returning NaNs--replace
FillTriangular
withFillScaleTriL
and apply Chaining to first transpose input.
greta 0.4.5
Bug Fixes
- Remove trailing comma bug in glue #618
greta 0.4.4
Bug fixes
- Some small documentation bugs were fixed, namely the sentinel "_PACKAGE" documentation, and various small changes to correctly export S3 methods.
greta 0.4.3
Features
- Adds
reinstall_greta_deps()
, which helps with starting from a clean slate when installing greta dependencies (#524)
Fixes
greta 0.4.2
Fixes
- workaround for M1 issues (#507)
greta 0.4.1
Summary
This release presents a variety of improvements over the past 2 years. We are now aiming to have smaller, more regular releases of greta
. This release showcases new features implemented by Nick Golding on the calculate
and simulate
functions. There are also many internal changes on installation, error printing, and testing. This release also sees changing of maintainer, from Nick Golding to Nick Tierney.
Installation
We have overhauled the installation checking process, and created a new helper function for installation, install_greta_deps()
.
We need the Tensorflow and Tensorflow Probability Python modules to use greta
.
When these aren't installed, this now triggers a new prompt which encourages users
to use a new installation helper, which looks like this:
#> We have detected that you do not have the expected python packages setup.
#> You can set these up by running this R code in the console:
#> `install_greta_deps()`
#> Then, restart R and run:
#> `library(greta)`
#> (Note: Your R session should not have initialised Tensorflow yet.)
#> For more information, see `?install_greta_deps`
Running install_greta_deps()
will then go through the process of installing the dependencies, and ask the user to restart R and load greta
to get it working:
#> ✓ Installation of greta dependencies is complete!
#> • Restart R, then load greta with: `library(greta)`
The install_greta_deps()
function helps ensure Python dependencies are installed correctly. This saves exact versions of Python (3.7), and the python modules NumPy (1.16.4), Tensorflow (1.14.0), and Tensorflow Probability (0.7.0) into a conda environment, "greta-env".
So what is a conda environment? It is similar to the R projects, packrat
and renv
(although I believe conda environments are a much older idea!). It allows you to use specific versions of Python and Python modules (Python module = R Package) that do not interact with other projects. Essentially, you "activate" a specific conda environment, which loads the specified Python version and modules. This means you avoid situations where you might update a python module and then all your other code breaks because breaking changes were introduced in a new version.
Why do we need this? Currently greta
needs specific versions of Tensorflow and Tensorflow Probability, and we know that those specific versions work with a specific version of Python. We wanted to keep things stable for users, so they don't have to go through the (often) painful process of installing dependencies.
How does it work? When greta
is loaded, say with library(greta)
, it searches for a "greta-env" conda environment and loads it. It is not required to use the conda environment, "greta-env", so you can install these Python modules yourself.
Overall this means that users can run the function install_greta_deps()
, follow the prompts, and have all the python modules they need installed, without contaminating other software that use different python modules.
Error printing
We have reviewed all of the error messages in greta, and rewritten the printing methods for the error messages to use the cli
package for prettier, more informative testing. We have also used the glue
package in place of most uses of sprintf
or paste/0
, as the literal string interpolation makes it easier to maintain. For example:
paste0("Objects is of class: ", class(10))
#> [1] "Objects is of class: numeric"
sprintf("Objects is of class: %s", class(10))
#> [1] "Objects is of class: numeric"
glue::glue("Objects is of class: {class(10)}")
#> Objects is of class: numeric
cat(cli::format_message("Objects is of class: {.cls {class(10)}}"))
#> Objects is of class: <numeric>
Using cli
also means we get nifty outputs like this from the new greta_sitrep()
function, which tests if Python and its dependencies are available
greta::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!
Testing
We have also overhauled the testing interface to use snapshotting. This makes it easier to write and test new error messages, and identify issues with existing print methods, errors, and warnings.
Looking to the future
In a future release we will switch to using TensorFlow 2.6 (or higher), to ensure greta
works with Apple computers with an M1 chip. We note that we have gone from "skipped" version 0.4.0, however this is because we had a soft release of 0.4.0 on GitHub in December, and wanted to signify that this package has changed since that time.
Thanks
A special thanks to everyone who helped with this release: Nick Golding, Jacob Wujciak-Jens, and Maëlle Salmon.
Fixes:
-
Python is now initialised when a
greta_array
is created (#468). -
head and tail S3 methods for
greta_array
are now consistent with head and tail methods for R versions 3 and 4 (#384). -
greta_mcmc_list
objects (returned bymcmc()
) are now no longer modified by operations (likecoda::gelman.diag()
). -
joint distributions of uniform variables now have the correct constraints when sampling (#377).
-
array-scalar dispatch with 3D arrays is now less buggy (#298).
-
greta
now provides R versions of all of R's primitive functions (I think), to prevent them from silently not executing (#317). -
Uses
Sys.unsetenv("RETICULATE_PYTHON")
in.onload
on package startup,
to prevent an issue introduced with the "ghost orchid" version of RStudio where they do not find the current version of RStudio. See #444 for more details. -
Internal change to code to ensure
future
continues to support parallelisation of chains. See #447 for more details. -
greta
now depends onfuture
version 1.22.1,tensorflow
(the R package) 2.7.0, andparallelly
1.29.0. This should see no changes on the user side.
API changes:
-
Now depends on R >= 3.1.0 (#386)
-
chol2inv.greta_array()
now warns user about LINPACK argument being ignored, and also reminds user it has been deprecated since R 3.1 -
calculate()
now accepts multiple greta arrays for which to calculate values, via the...
argument. As a consequence any other arguments must now be named. -
A number of optimiser methods are now deprecated, since they will be unavailable when greta moves to using TensorFlow v2.0:
powell()
,cg()
,newton_cg()
,l_bfgs_b()
,tnc()
,cobyla()
, andslsqp()
. -
dirichlet()
now returns a variable (rather than an operation) greta array, and the graphs created bylkj_correlation()
andwishart()
are now simpler as cholesky-shaped variables are now available internally. -
Adds the
reinstall_greta_env()
,reinstall_miniconda()
,remove_greta_env()
, andremove_miniconda()
helper functions for helping installation get to "clean slate" (#443). -
greta
currently doesn't work on Apple Silicon (M1 Macs) as they need to use TF 2.0, which is currently being implemented.greta
now throws an error if M1 macs are detected and directs users to #458 (#487)
Features:
-
New
install_greta_deps()
- provides installation of python dependencies (#417). This saves exact versions of Python (3.7), and the python modules NumPy (1.16.4), Tensorflow (1.14.0), and Tensorflow Probability (0.7.0) into a conda environment, "greta-env". When initialising Python, greta now searches for this conda environment first, which presents a great advantage as it isolates these exact versions of these modules from other Python installations. It is not required to use the conda environment, "greta-env". Overall this means that users can run the functioninstall_greta_deps()
, follow the prompts, and have all the python modules they need installed, without contaminating other software that use different python modules. -
calculate()
now enables simulation of greta array values from their priors, optionally conditioned on fixed values or posterior samples. This enables prior and posterior predictive checking of models, and simulation of data. -
A
simulate()
method for greta models is now also provided, to simulate the values of all greta arrays in a model from their priors. -
variable()
now accepts arrays forupper
andlower
, enabling users to define variables with different constraints. -
There are three new variable constructor functions:
cholesky_variable()
,simplex_variable()
, andordered_variable()
, for variables with these constraints but no probability distribution. -
New
chol2symm()
is the inverse ofchol()
. -
mcmc()
,stashed_samples()
, andcalculate()
now return objects of classgreta_mcmc_list
which inherit fromcoda
'smcmc.list
class, but enable custom greta methods for manipulating mcmc outputs, including awindow()
function. -
mcmc()
andcalculate()
now have atrace_batch_size
argument enabling users to trade-off computation speed versus memory requirements when calculating posterior samples for target greta arrays (#236). -
Many message, w...
greta 0.3.1
This release is predominantly a patch to make greta work with recent versions of TensorFlow and TensorFlow Probability, which were not backward compatible with the versions on which greta previously depended. From this release forward, greta will depend on specific (rather than minimum) versions of these two pieces of software to avoid it breaking if more changes are made to the APIS of these packages.
version 0.3.0
Merge pull request #235 from greta-dev/rc_0_3_0 v0.3.0 release candidate
version 0.2.5
Merge pull request #194 from greta-dev/update_readme_installation update installation instructions in the readme
version 0.2.4
Merge pull request #136 from greta-dev/dev v0.2.4 release candidate