Apparently is a common error when you are using RStudio a Macbook with M1 or M2. So when I try to call this function i get always the following error (of course after installed tensorflow and eras packages and called its library):
network <- keras_model_sequential() %>%
layer_dense(units = 32, activation = "relu", input_shape = 4, name = 'dense_1') %>%
layer_dense(units = 1)
Error: Valid installation of TensorFlow not found.
Python environments searched for 'tensorflow' package:
/usr/bin/python3
Python exception encountered:
Traceback (most recent call last):
File "/Library/Frameworks/R.framework/Versions/4.3-x86_64/Resources/library/reticulate/python/rpytools/loader.py", line 119, in _find_and_load_hook
return _run_hook(name, _hook)
File "/Library/Frameworks/R.framework/Versions/4.3-x86_64/Resources/library/reticulate/python/rpytools/loader.py", line 93, in _run_hook
module = hook()
File "/Library/Frameworks/R.framework/Versions/4.3-x86_64/Resources/library/reticulate/python/rpytools/loader.py", line 117, in _hook
return find_and_load(name, import)
ModuleNotFoundError: No module named 'tensorflow'
You can install TensorFlow using the install_tensorflow() function.