@@ -3,7 +3,6 @@ data_node <- R6Class(
3
3
inherit = node ,
4
4
public = list (
5
5
initialize = function (data ) {
6
- # # browser()
7
6
# coerce to an array with 2+ dimensions
8
7
data <- as_2d_array(data )
9
8
@@ -150,26 +149,7 @@ operation_node <- R6Class(
150
149
mode <- dag $ how_to_define(self )
151
150
# if sampling get the distribution constructor and sample this
152
151
if (mode == " sampling" ) {
153
- # browser()
154
152
tensor <- dag $ draw_sample(self $ distribution )
155
-
156
- # if (has_representation(self, "cholesky")) {
157
- # browser()
158
- # cholesky_tensor <- tf_chol(tensor)
159
- # # cholesky_tf_name <- dag$tf_name(self$representation$cholesky)
160
- # cholesky_node <- get_node(representation(self, "cholesky"))
161
- # cholesky_tf_name <- dag$tf_name(cholesky_node)
162
- # assign(cholesky_tf_name, cholesky_tensor, envir = tfe)
163
- # # TF1/2
164
- # # This assignment I think is supposed to be passed down to later on
165
- # # in the script, as `cholesky_tf_name` gets overwritten
166
- # cholesky_tf_name <- dag$tf_name(self)
167
- # tf_name <- cholesky_tf_name
168
- # tensor <- cholesky_tensor
169
- # cholesky_tensor <- tf_chol(tensor)
170
- # cholesky_tf_name <- dag$tf_name(self$representation$cholesky)
171
- # assign(cholesky_tf_name, cholesky_tensor, envir = dag$tf_environment)
172
- # }
173
153
}
174
154
175
155
if (mode == " forward" ) {
@@ -188,11 +168,9 @@ operation_node <- R6Class(
188
168
operation <- eval(parse(text = self $ operation ),
189
169
envir = self $ tf_function_env
190
170
)
191
- # browser()
192
171
tensor <- do.call(operation , tf_args )
193
172
}
194
173
195
- # browser()
196
174
# assign it in the environment
197
175
assign(tf_name , tensor , envir = dag $ tf_environment )
198
176
}
@@ -212,7 +190,6 @@ variable_node <- R6Class(
212
190
upper = Inf ,
213
191
dim = NULL ,
214
192
free_dim = prod(dim )) {
215
- # # browser()
216
193
check_if_lower_upper_numeric(lower , upper )
217
194
218
195
# replace values of lower and upper with finite values for dimension
@@ -283,33 +260,24 @@ variable_node <- R6Class(
283
260
mode <- dag $ how_to_define(self )
284
261
285
262
if (mode == " sampling" ) {
286
- # browser()
287
263
distrib_node <- self $ distribution
288
264
289
265
if (is.null(distrib_node )) {
290
266
# does it have an anti-representation where it is the cholesky?
291
267
# the antirepresentation of cholesky is chol2symm
292
- # if it does, we will take the antirepresentation and get it to `tf` itself
293
- # then we need to get the tf_name
268
+ # if yes, we take antirep and get it to `tf`, then get the tf_name
294
269
chol2symm_ga <- self $ anti_representations $ chol2symm
295
270
chol2symm_existing <- ! is.null(chol2symm_ga )
271
+
296
272
if (chol2symm_existing ) {
273
+
297
274
chol2symm_node <- get_node(chol2symm_ga )
298
275
chol2symm_name <- dag $ tf_name(chol2symm_node )
299
276
chol2symm_tensor <- get(chol2symm_name , envir = dag $ tf_environment )
300
277
tensor <- tf_chol(chol2symm_tensor )
278
+
301
279
}
302
280
303
- # chol2symm_ga$define_tf(dag)
304
- # } else {
305
- #
306
- # # if the variable has no distribution create a placeholder instead
307
- # # (the value must be passed in via values when using simulate)
308
- # shape <- to_shape(c(1, self$dim))
309
- # # TF1/2 check
310
- # # need to change the placeholder approach here.
311
- # # NT: can we change this to be a tensor of the right shape with 1s?
312
- # tensor <- tensorflow::as_tensor(1L, shape = shape, dtype = tf_float())
313
281
} else {
314
282
tensor <- dag $ draw_sample(self $ distribution )
315
283
}
@@ -432,10 +400,8 @@ distribution_node <- R6Class(
432
400
discrete = FALSE ,
433
401
multivariate = FALSE ,
434
402
truncatable = TRUE ) {
435
- # # browser()
436
403
super $ initialize(dim )
437
404
438
- # # browser()
439
405
# for all distributions, set name, store dims, and set whether discrete
440
406
self $ distribution_name <- name
441
407
self $ discrete <- discrete
@@ -462,7 +428,6 @@ distribution_node <- R6Class(
462
428
463
429
# create a target variable node (unconstrained by default)
464
430
create_target = function (truncation ) {
465
- # #browser()
466
431
vble(truncation , dim = self $ dim )
467
432
},
468
433
list_parents = function (dag ) {
@@ -494,7 +459,6 @@ distribution_node <- R6Class(
494
459
495
460
# create target node, add as a parent, and give it this distribution
496
461
add_target = function (new_target ) {
497
- # #browser()
498
462
# add as target and as a parent
499
463
self $ target <- new_target
500
464
self $ add_parent(new_target )
@@ -621,7 +585,6 @@ node_classes_module <- module(
621
585
622
586
# shorthand for distribution parameter constructors
623
587
distrib <- function (distribution , ... ) {
624
- # #browser()
625
588
check_tf_version(" error" )
626
589
627
590
# get and initialize the distribution, with a default value node
0 commit comments