解决importtensorflowastf出错的原因
笔者在运⾏ import tensorflow as tf时出现下⾯的错误,但在运⾏import tensorflow时没有出错。
>>> import tensorflow as tf
RuntimeError: module compiled against API version 0xc but this version of numpy is 0xa
ImportError: ultiarray failed to import
ImportError: umath failed to import
ImportError: umath failed to import
2018-12-09 01:22:17.925262: F tensorflow/python/lib/:675] Check failed: PyBfloat16_Type.tp_base != nullp
tr
后运⾏keras初级教程上的以下代码也报错:
# univariate lstm example
from numpy import array
dels import Sequential
from keras.layers import LSTM
from keras.layers import Dense
# define dataset
X = array([[10, 20, 30], [20, 30, 40], [30, 40, 50], [40, 50, 60]])
y = array([40, 50, 60, 70])
numpy教程 pdf# reshape from [samples, timesteps] into [samples, timesteps, features]
X = X.reshape((X.shape[0], X.shape[1], 1))
# define model
model = Sequential()
model.add(LSTM(50, activation='relu', input_shape=(3, 1)))
model.add(Dense(1))
modelpile(optimizer='adam', loss='mse')
# fit model
model.fit(X, y, epochs=1000, verbose=0)
# demonstrate prediction
x_input = array([50, 60, 70])
x_input = shape((1, 3, 1))
yhat = model.predict(x_input, verbose=0)
print(yhat)
经查阅资料后,安装以下⽹站的pip install tf-nightly
安装完成后运⾏上⾯所有代码就OK了,特此分享!
到此这篇关于解决import tensorflow as tf 出错的原因的⽂章就介绍到这了,更多相关import tensorflow as tf 内容请搜索以前的⽂章或继续浏览下⾯的相关⽂章希望⼤家以后多多⽀持!

版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系QQ:729038198,我们将在24小时内删除。