解决import tensorflow as tf 出错的原因
笔者在运行 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: numpy.core.multiarray failed to import ImportError: numpy.core.umath failed to import ImportError: numpy.core.umath failed to import 2018-12-09 01:22:17.925262: F tensorflow/python/lib/core/bfloat16.cc:675] Check failed: PyBfloat16_Type.tp_base != nullp tr
后运行keras初级教程上的以下代码也报错:
# univariate lstm example from numpy import array from keras.models 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]) # 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)) model.compile(optimizer='adam', loss='mse') # fit model model.fit(X, y, epochs=1000, verbose=0) # demonstrate prediction x_input = array([50, 60, 70]) x_input = x_input.reshape((1, 3, 1)) yhat = model.predict(x_input, verbose=0) print(yhat)
经查阅资料后,安装以下网站的pip install tf-nightly
https://pypi.org/project/tf-nightly/
安装完成后运行上面所有代码就OK了,特此分享!
到此这篇关于解决import tensorflow as tf 出错的原因的文章就介绍到这了,更多相关import tensorflow as tf 内容请搜索脚本之家以前的文章或继续浏览下面的相关文章希望大家以后多多支持脚本之家!
相关文章
selenium获取当前页面的url、源码、title的方法
这篇文章主要介绍了selenium获取当前页面的url、源码、title的方法,文中通过示例代码介绍的非常详细,对大家的学习或者工作具有一定的参考学习价值,需要的朋友们下面随着小编来一起学习学习吧2019-06-06
手把手教你打造个性化全栈应用Python Reflex框架全面攻略
Reflex框架是为了解决传统全栈开发中的一些挑战而诞生的,它充分利用了现代前端框架(如React)的优势,与后端技术(如Node.js)深度集成,使得开发者能够更加流畅地构建整个应用,Reflex的设计理念包括简化、响应性和一致性,旨在提高全栈开发的效率和可维护性2023-12-12
详解Pytorch 使用Pytorch拟合多项式(多项式回归)
这篇文章主要介绍了详解Pytorch 使用Pytorch拟合多项式(多项式回归),小编觉得挺不错的,现在分享给大家,也给大家做个参考。一起跟随小编过来看看吧2018-05-05
python实现几种归一化方法(Normalization Method)
这篇文章主要介绍了python实现几种归一化方法(Normalization Method),文中通过示例代码介绍的非常详细,对大家的学习或者工作具有一定的参考学习价值,需要的朋友们下面随着小编来一起学习学习吧2019-07-07


最新评论