Keras Sequential Model
Creating the model | Specifying input size and batch size | specifying the activation function
Sequential Model : Linear stack of layers.
Create a Sequential Model by passing the layer instances to the constructor.
Import sequential model from Keras models.
from keras.models import Sequential
Import dense layer and activation function from keras layers
Create sequential model
Input = can be of any dimension or a single element
Shape = length along each dimension of the input
Model needs to know the input shape it expects.
Only the first layer of the sequential model should know its input shape.
Batch = collection of inputs
Batch Size = no of inputs
- Create the model
model = Sequential()
- Create the layer with batch size of 32 and input size of 784
Dense(32,input_dim=784)
- Add the layer to the model
model.add(Dense(32,input_dim=784))
- Add the activation function to the layer
model.add(Activation('relu'))
Full Code
from keras.models import Sequential
#import dense layer and activation function from karas layers
from keras.layers import Dense, Activation
#create sequential model
model = Sequential()
#add layer to the model
model.add(Dense(32, input_dim=784))
#add activation function to the layer
model.add(Activation('relu'))
Comments
Post a Comment