import numpy as np
from keras.models import Sequential
from keras.layers import Dense
# 랜덤시드 고정시키기
np.random.seed(5)
# 데이터셋 불러오기
pimaIndians = np.loadtxt("pimaIndians.txt", delimiter=",")
# 입력(X)과 출력(Y) 변수로 분리하기
X = pimaIndians[:, 0:8]
Y = pimaIndians[:, 8]
# 모델 구성하기
model = Sequential()
model.add(Dense(12, input_dim=8, init='uniform', activation='relu'))
model.add(Dense(8, init='uniform', activation='relu'))
model.add(Dense(1, init='uniform', activation='sigmoid'))
# 모델 엮기
model.compile(loss='binary_crossentropy', optimizer='adam', metrics=['accuracy'])
# 모델 학습시키기
model.fit(X, Y, nb_epoch=100, batch_size=10)
# 모델 평가하기
scores = model.evaluate(X, Y)
print("%s: %.2f%%" %(model.metrics_names[1], scores[1]*100))
[출처]
https://tykimos.github.io/Keras/2017/02/04/MLP_Getting_Started/