The documentation for the R package keras3 indicates that attaching it also attaches tensorflow. I can see in the initiation code resulting from:

keras3::install_keras()

that this does, indeed, attach the tensorflow library, but it evidently doesn't attach the tensorflow R package, as the following code fails:

tf$constant("Hello TensorFlow!')

If I specifically attach the tensorflow R package:

library(tensorflow)

Then the above code works.

So attaching the R package tensorflow evidently does something that achieves "import tensorflow as tf" that is not done by simply attaching keras3.

In summary, while attaching keras3 attaches the tensorflow library, it doesn't create a way to call tensorflow functions directly from R.

Of course, I can simply attach the R tensorflow package myself. But when I do that, I am told that the tensorflow package masks two tensorflow functions from keras3: set_random_seed and shape. In general, it would seem preferable not to load the tensorflow library twice.

So, finally, my question is whether it is possible to run the magic that library(tensorflow) activates to permit tensorflow calls directly from R without attaching the rest of the R tensorflow package.

Thanks in advance for any help with the above.

Larry Hunscker

Running R 4.4.1/RStudio 2024.04.2 Build 764 on a 64-bit Windows 11 laptop.