我正在使用安装在环境anaconda4.7.10中的R studio v1.2.1335(R markdown和reticulate包),python3.7.4。你知道吗
正在处理此代码(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()
```
错误:
Evaluation error: option error has NULL value.
使用keras和comand Dense的其他代码也会出现同样的错误。你知道吗
使用py\u 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
---------------更新------------------- 我已经在Rstudio中运行了这个脚本,没有使用r-markdown,但是只使用python 而且它没有出错。问题一定出在r减价或网状安装中。你知道吗
任何帮助都将不胜感激
目前没有回答
相关问题 更多 >
编程相关推荐