Hands-On Neural Networks with Keras
上QQ阅读APP看书,第一时间看更新

Keras's sequential API

As you may well know, each Python library often comes with a core data abstraction that defines the data structure that the library is able to manipulate to perform computations. NumPy has its arrays, while pandas has its DataFrames. The core data structure of Keras is a model, which is essentially a manner to organize layers of interconnected neurons. We will start with the simplest type of model: the sequential model (https://keras.io/getting-started/sequential-model-guide/). This is available as a linear stack of layers through the sequential API. More complex architectures also allow us to review the functional API, which is used to build custom layers. We will cover these later. The following code imports the sequential model, as well as some of the layers we will be using to build our first network:

from keras.models import Sequential
from keras.layers import Flatten, Dense, Dropout
from keras.layers.core import Activation
from keras import backend as K