from keras.models import Sequential from keras.layers import Dense model = Sequential() model.add(Dense(10, input_dim=5, activation='relu')) model.add(Dense(5, activation='relu')) model.add(Dense(1, activation='sigmoid'))
import keras from keras.models import Sequential from keras.layers import Conv2D, MaxPooling2D, Flatten, Dense model = Sequential() model.add(Conv2D(32, (3, 3), padding='same', input_shape=(28, 28, 1), activation='relu')) model.add(MaxPooling2D(pool_size=(2, 2))) model.add(Conv2D(64, (3, 3), activation='relu')) model.add(MaxPooling2D(pool_size=(2, 2))) model.add(Flatten()) model.add(Dense(128, activation='relu')) model.add(Dense(10, activation='softmax'))In both examples, `keras.models.Sequential` is used to define the linear architecture of the model. The first example creates a simple fully connected neural network with three dense layers, whereas the second example uses CNN layers to extract features from images. Keras is a deep learning library that sits on top of TensorFlow or Theano, and provides an API to make it easier to build deep learning models.