I'm working with R studio v1.2.1335 (r markdown and reticulate package), Python 3.7.4 installed in environment Anaconda 4.7.10.
Struggling with this code (https://www.guru99.com/keras-tutorial.html)
```{python script 1}
import keras
from keras.models import Sequential
from keras.layers import Dense, Activation
import numpy as np
import matplotlib.pyplot as plt
x = data = np.linspace(1,2,200)
y = x*4 + np.random.randn(*x.shape) * 0.3
model = Sequential()
model.add(Dense(1, input_dim=1, activation='linear'))
model.compile(optimizer='sgd', loss='mse', metrics=['mse'])
weights = model.layers[0].get_weights()
w_init = weights[0][0][0]
b_init = weights[1][0]
print('Linear regression model is initialized with
weights w: %.2f, b: %.2f' % (w_init, b_init))
model.fit(x,y, batch_size=1, epochs=30, shuffle=False)
weights = model.layers[0].get_weights()
w_final = weights[0][0][0]
b_final = weights[1][0]
print('Linear regression model is trained to have
weight w: %.2f, b: %.2f' % (w_final, b_final))
predict = model.predict(data)
plt.plot(data, predict, 'b', data , y, 'k.')
plt.show()
```
error:
Evaluation error: option error has NULL value.
the same error happens with other code that use keras and comand Dense.
others info with py_config()
python: C:\Users\Megaport\Anaconda3\envs\r-reticulate\python.exe
libpython: C:/Users/Megaport/Anaconda3/envs/r-reticulate/python37.dll
pythonhome: C:\Users\Megaport\ANACON~1\envs\R-RETI~1
version: 3.7.4 (default, Aug 9 2019, 18:34:13) [MSC v.1915 64 bit (AMD64)]
Architecture: 64bit
numpy: C:\Users\Megaport\ANACON~1\envs\R-RETI~1\lib\site-packages\numpy
numpy_version: 1.17.2
python versions found:
C:\Users\Megaport\Anaconda3\envs\r-reticulate\python.exe
C:\Users\Megaport\ANACON~1\python.exe
C:\Users\Megaport\Anaconda3\python.exe
C:\Users\Megaport\Anaconda3\envs\venv\python.exe
-------------------- UPDATE ------------------- I've run the script in Rstudio without r-markdown but only with python and it worked without errors. The problem must be in r-markdown or reticulate installation.
Any help would be appreciated