# Simple Example

The core data structure of Keras is a model, a way to organize layers. The simplest type of model is the Sequential model, a linear stack of layers. For more complex architectures, you should use the Keras functional API, which allows to build arbitrary graphs of layers.

from keras.models import Sequential, Dense

# Construct Sequential model
model = Sequential()

# Stacking layers by .add()

# Configure its learning process with .compile()
model.compile(loss='categorical_crossentropy',
optimizer='sgd',
metrics=['accuracy'])

# Iterate on the training data in batches
model.fit(x_train, y_train, epochs=5, batch_size=32)

# Alternatively, you can feed batches to your model manually:
model.train_on_batch(x_batch, y_batch)

# Evaluate performance:
loss_and_metrics = model.evaluate(x_test, y_test, batch_size=128)

# Generate predictions on new data:
classes = model.predict(x_test, batch_size=128)