Keras 是一个高级神经网络 API,可以运行在 TensorFlow、CNTK 或 Theano 后端之上。它被设计为易于使用且可扩展,可以快速原型设计并实验深度学习模型。

快速开始

安装 Keras

首先,确保你已经安装了 TensorFlow、CNTK 或 Theano。然后,你可以使用以下命令安装 Keras:

pip install keras

创建一个简单的模型

以下是一个使用 Keras 创建的简单神经网络模型示例:

from keras.models import Sequential
from keras.layers import Dense

model = Sequential()
model.add(Dense(12, input_dim=8, 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(X_train, y_train, epochs=150, batch_size=10)

资源

图片

  • Neural_Networks
  • Machine_Learning
  • Deep_Learning