Skip to content

Instantly share code, notes, and snippets.

@njtierney
Created August 25, 2022 05:54
Show Gist options
  • Save njtierney/bb5b27f978dab551435861772ec79ef1 to your computer and use it in GitHub Desktop.
Save njtierney/bb5b27f978dab551435861772ec79ef1 to your computer and use it in GitHub Desktop.
###
# currently a lot of the helper functions in greta need to be rewritten as they
# use various TF1 things that break a lot of existing code
# and as far as I can tell, there are issues with how some of the code
# is initialising TF with dag$define_tf()
# - so this is happening and then the free state doesn't
# exist...and I'm not sure how to resolve this
# current tests that fail:
# (2 errors) test_calculate (with random seed issues)
# (34 errors) test_distributions
# (compare_distributions fails)
# Also fails when sampling multivariate normal
# also get an error like:
# 'tensorflow_probability.python.distributions' has no attribute 'Wishart'
# also an error about `dag$tf_log_prob_function(tf_parameters)`:
# Expected float64, but got Tensor("Const_1:0", shape=(5,), dtype=float64)
# of type 'Tensor'.
# also an error of:
# `get(self$tf_name(node), envir = self$tf_environment)`:
# object 'all_forward_distribution_1' not found
# (2 errors) test_extract_replace_combine
# object `sess` not found
# to do with
# dag$set_tf_data_list("batch_size", 1L)
# dag$build_feed_dict()
# out <- dag$tf_sess_run(dag$tf_name(node), as_text = TRUE)
# drop_first_dim(out)
# (6 errors) test_functions
# (`grab` fails) - re `sess` same as `test_extract_replace_combine`
# test_iid_samplers: compare_iid_samples is a bit broken for
# inverse_gamma, weibull, and wishart
# not sure how to grab the right component out
# # there are some instances of `placeholder` that need to be fixed
# e.g., in node_types.R: - I'm not sure what to give this here
# if (mode == "sampling") {
# distrib_node <- self$distribution
#
# if (is.null(distrib_node)) {
#
# # if the variable has no distribution create a placeholder instead
# # (the value must be passed in via values when using simulate)
# shape <- to_shape(c(1, self$dim))
# # TF1/2
# # need to change the placeholder approach here.
# # NT: can we change this to be a tensor of the right shape with 1s?
# # tensor <- tf$compat$v1$placeholder(shape = shape, dtype = tf_float())
# browser()
# tensor <- tensorflow::as_tensor(1L, shape = shape, dtype = tf_float())
# } else {
# tensor <- dag$draw_sample(self$distribution)
# }
# }
# (7 errors) test_joint
# seems to fail when calling MCMC...in some cases
# also has errors:
# `get(self$tf_name(node), envir = self$tf_environment)`:
# object 'all_forward_distribution_1' not found
# TypeError: Expected float64, but got
# Tensor("Const:0", shape=(3,), dtype=float64) of type 'Tensor'.
# (3 errors) test_misc seems to fail from
# `grab` error about `sess`
# and snapshot errors
# (7 errors) test_mixture seems to fail with compare_distribution with
# dag$evaluate_density
# also error - `get(self$tf_name(node), envir = self$tf_environment)`:
# object 'all_forward_distribution_1' not found
# # and
# Evaluation error: TypeError: Expected float64, but got
# Tensor("Const:0", shape=(3,), dtype=float64) of type 'Tensor'.
# (2 errors) test_operators
# Failing because of `grab`, and `grab_via_free_state`
# `eval(expr)`: object 'sess' not found, and
# TypeError: Expected int32, but got 0.0 of type 'float'.
# (6 errors) test_representations
# fails because of `greta_density`
# error message is
# `get(self$tf_name(node), envir = self$tf_environment)`:
# object 'all_forward_distribution_1' not found
# (1 error) test_simulate fails
# because of an issue with RNG seed not being passed
# (14 errors) test_truncated
# fails because of `greta_density`
# error message
# `get(self$tf_name(node), envir = self$tf_environment)`:
# object 'all_forward_distribution_1' not found
# (3 errors) test_variables fails due to some error regarding
# AttributeError: module 'tensorflow_probability.python.bijectors'
# has no attribute 'Ordered'
# TypeError: Expected float64, but got
# Tensor("Const:0", shape=(3,), dtype=float64) of type 'Tensor'.
###
###
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment