[問題] binary 精準度

作者: HideOnATC (Hideon)   2020-05-15 20:55:04
如題 小弟在跑下面程式的時候 精準度都一直是0
不知道是哪裡出了問題 還請各位神人指點
import tensorflow as tf
import numpy as np
import matplotlib.pyplot as plt
import pandas as pd
from tensorflow.keras.models import Sequential
from tensorflow.keras.layers import Dense
from tensorflow.keras import metrics
df = pd.read_csv("./diabetes.csv")
np.random.seed(10)
dataset = df.values
np.random.shuffle(dataset)
X = dataset[:, 0:8]
Y = dataset[:, 8]
model = Sequential()
model.add(Dense(10,input_shape=(8, ),activation="relu"))
model.add(Dense(8,activation="relu"))
model.add(Dense(1,activation="sigmoid"))
model.compile(loss="binary_crossentropy",optimizer="sgd",metrics=['binary_accuracy'])
model.fit(X,Y,epochs=100,batch_size=10)
loss, acc = model.evaluate(X,Y)
print("Accuracy is {:.2f}".format(acc))

Links booklink

Contact Us: admin [ a t ] ucptt.com