我正在尝试使用keras测试我在深度学习模型中的分裂 这是我的代码
from keras.models import Sequential
from keras.layers import Dense, Dropout
import numpy as np
from scipy import signal
import matplotlib.pyplot as plt
import pandas as pd
import itertools
np.random.seed(7)
train = np.loadtxt("TrainDatasetFinal.txt", delimiter=",")
test = np.loadtxt("testDatasetFinal.txt", delimiter=",")
y_train = train[:,7]
y_test = test[:,7]
magnitude_training = train[:,5]
norm_train = (magnitude_training - np.mean(magnitude_training))/np.std(magnitude_training)
magnitude_testing = test[:,5]
norm_test = (magnitude_testing - np.mean(magnitude_testing))/np.std(magnitude_testing)
model = Sequential()
model.add(Dense(12, input_dim=1, activation='relu'))
model.add(Dense(8, activation='relu'))
model.add(Dense(1, activation='sigmoid'))
model.compile(loss='binary_crossentropy' , optimizer='adam', metrics=['accuracy'])
model.fit(norm_train, y_train, epochs=2, batch_size=64, verbose=2)
score=model.evaluate(norm_test, y_test, verbose=2)
print(score)
对于培训,它给了我以下输出
Epoch 1/2
- 34s - loss: 0.2077 - acc: 0.9430
Epoch 2/2
- 35s - loss: 0.2027 - acc: 0.9430
但测试输出我无法理解
[0.22448099704202343, 0.939972481247623]
这两个数字是什么?
答案 0 :(得分:4)
0.22448099704202343:测试损失
0.939972481247623:测试准确度
答案 1 :(得分:0)
如果打印model.metrics_names
,您将得到输出['loss', 'acc']