解決import tensorflow as tf 出錯(cuò)的原因
筆者在運(yùn)行 import tensorflow as tf時(shí)出現(xiàn)下面的錯(cuò)誤,但在運(yùn)行import tensorflow時(shí)沒(méi)有出錯(cuò)。
>>> 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
后運(yùn)行keras初級(jí)教程上的以下代碼也報(bào)錯(cuò):
# 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)
經(jīng)查閱資料后,安裝以下網(wǎng)站的pip install tf-nightly
https://pypi.org/project/tf-nightly/
安裝完成后運(yùn)行上面所有代碼就OK了,特此分享!
到此這篇關(guān)于解決import tensorflow as tf 出錯(cuò)的原因的文章就介紹到這了,更多相關(guān)import tensorflow as tf 內(nèi)容請(qǐng)搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持腳本之家!
相關(guān)文章
Python中的list.sort()方法和函數(shù)sorted(list)
這篇文章主要介紹了Python中的list.sort()方法和函數(shù)sorted(list),sort()是列表的方法,修改原列表使得它按照大小排序,沒(méi)有返回值,返回None2022-08-08Pythony運(yùn)維入門之Socket網(wǎng)絡(luò)編程詳解
這篇文章主要介紹了Pythony運(yùn)維入門之Socket網(wǎng)絡(luò)編程,文中通過(guò)示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來(lái)一起學(xué)習(xí)學(xué)習(xí)吧2019-04-04Pandas 實(shí)現(xiàn)分組計(jì)數(shù)且不計(jì)重復(fù)
這篇文章主要介紹了Pandas 實(shí)現(xiàn)分組計(jì)數(shù)且不計(jì)重復(fù)的操作,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。一起跟隨小編過(guò)來(lái)看看吧2021-03-03Python計(jì)算素?cái)?shù)個(gè)數(shù)的兩種方法
本文主要介紹了Python計(jì)算素?cái)?shù)個(gè)數(shù)的兩種方法,文中通過(guò)示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來(lái)一起學(xué)習(xí)學(xué)習(xí)吧2023-05-05