1 of 4

BASIC SYNTAX OF KERAS!!!!

from keras.models import Sequential

from keras.layers import Dense

model = Sequential([Dense(2, input_dim=1), Dense(1)])

Layers can also be added piecewise:

model.add(Dense(2, input_dim=1))

model.add(Dense(1))

This is the main object we create for our model where we stack our layers one upon another

2 of 4

BASIC SYNTAX OF KERAS!!!!

Dense //dense creates a dense layer that is fully connected layer with mentioned perceptron

Arguments:

  1. units: Positive integer, dimensionality of the output space.

  1. activation: Activation function to use . If you don't specify anything, no activation is applied (ie. "linear" activation: a(x) = x).

  1. input_dim: no of inputs if the layer is first layer

3 of 4

compile //compile is used to finally stack all the layer one above the another and build the complete model with given optimizer and metrics in concern

Arguments

  1. optimizer: String (name of optimizer) or optimizer instance. See optimizers.

  1. loss: String (name of objective function) or objective function or Loss instance. See losses in Keras Documentation. The loss value that will be minimized by the model will then be the sum of all individual losses.

4 of 4

BASIC SYNTAX OF KERAS!!!!

fit //fit is used to train the model and fit the regression line in the dataset

Arguments

x: Input data.

y: Target data.

batch_size: Integer or None.

epochs: Integer