使用张量流时,numpy出现问题,ModuleNotFoundError

时间:2019-03-28 20:22:58

标签: python tensorflow keras spyder

在第二个链接中找到本教程中的代码时,我得到了第一个链接中显示的错误。

https://imgur.com/a/0ytTTPy

https://machinelearningmastery.com/tutorial-first-neural-network-python-keras/

我尝试重新安装numpy并确保所有内容都是最新的。我在python 3.6上。

from keras.models import Sequential
from keras.layers import Dense
import numpy as np
# fix random seed for reproducibility
np.random.seed(7)

# load pima indians dataset
dataset = np.loadtxt("pima-indians-diabetes.csv", delimiter=",")
# split into input (X) and output (Y) variables
X = dataset[:,0:8]
Y = dataset[:,8]

# create model
model = Sequential()
model.add(Dense(12, input_dim=8, activation='relu'))
model.add(Dense(8, activation='relu'))
model.add(Dense(1, activation='sigmoid'))

# Compile model
model.compile(loss='binary_crossentropy', optimizer='adam', metrics=['accuracy'])

# Fit the model
model.fit(X, Y, epochs=150, batch_size=10)

# evaluate the model
scores = model.evaluate(X, Y)
print("\n%s: %.2f%%" % (model.metrics_names[1], scores[1]*100))

0 个答案:

没有答案