Hi,
I am trying to use Keras as part of my machine learning module.
I am trying to run the following code:
library(keras)
library(lubridate)
# load the data
dat = read.csv("data_energy_consumption.csv")
# convert full date into `month` and `hour`
dat$date = ymd_hms(dat$date) # now a UTC
dat$month = month(dat$date)
dat$hour = hour(dat$date)
# remove full date
dat = dat[, -2]
# store predictors and standardise
x = dat[, -1]
x = scale(x)
V = ncol(x) # for later
# convert from factor to numeric (0:normal, 1:high)
y = ifelse(dat$Appliances == "normal", 0, 1)
# one-hot encoding
y = to_categorical(y)
K = ncol(y) # number of classes
# check a few observations
y[c(1, 19, 105, 131)]
dat$Appliances[c(1, 19, 105, 131)]
Before running this, I installed Keras, and all lines fun fine up until the Keras function to_categorical(), when I run this line R results in a fatal error and shuts down the session.
My lecturer tried to help me fix this but we were unsuccessful, however, if I downgrade tensorflow package to version 1.4, I get a different error. Instead of the fatal error pop up and RStudio shutting dow, I get the following:
Error: Python module tensorflow.keras was not found. Detected Python configuration: python: /Users/cjclarke/Library/r-miniconda/envs/r-reticulate/bin/python libpython: /Users/cjclarke/Library/r-miniconda/envs/r-reticulate/lib/libpython3.6m.dylib pythonhome: /Users/cjclarke/Library/r-miniconda/envs/r-reticulate:/Users/cjclarke/Library/r-miniconda/envs/r-reticulate version: 3.6.12 |Anaconda, Inc.| (default, Sep 8 2020, 17:50:39) [GCC Clang 10.0.0 ] numpy: /Users/cjclarke/Library/r-miniconda/envs/r-reticulate/lib/python3.6/site-packages/numpy numpy_version: 1.19.5
I found a similar post on this forum, and it mentioned downgrading Cudnn to 7.0 instead of 7.1, however I have no idea what this is or how to do it, or even if it is an appropriate fix.
I would greatly appreciate any help as until I fix this, I cannot do my assignments.
Thanks in advance,
CJ