Professional Documents
Culture Documents
Deep - L - Notes - by Me
Deep - L - Notes - by Me
import numpy
numpy.random.seed(7)
X = dataset[:,0:8]
Y = dataset[:,8]
# create model
model = Sequential()
model.add(Dense(8, activation='relu'))
model.add(Dense(1, activation='sigmoid'))
# Compile model
model.compile(loss='binary_crossentropy', optimizer='adam',
metrics=['accuracy'])
scores = model.evaluate(X, Y)
NOTE:If you try running this example in an IPython or Jupyter notebook you may
get an error. The reason is the output progress bars during training. You can easily
turn these off by setting verbose=0 in the call to model.fit().
------------------------------------------------------------------------------------------------------
Define Network.
Compile Network.
Fit Network.
Evaluate Network.
Make Predictions.
1.)Neural networks are defined in Keras as a sequence of layers. The container for
these layers is the Sequential class.
The first step is to create an instance of the Sequential class. Then you can create
your layers and add them in the order that they should be connected.
model = Sequential()
model.add(Dense(2))
or layers = [Dense(2)]
model = Sequential(layers)
$Activation functions
Regression: Linear activation function or ‘linear’ and the number of neurons
matching the number of outputs.
$ Loss functions
$Optimizer
Stochastic Gradient Descent or ‘sgd‘ that requires the tuning of a learning rate and
momentum.
3.) Fit
4.)Evaluate
5.)Predict
predictions = model.predict(x)
-------------------------------------------------------------------------------------------------
3.)Iris flower dataset is well studied and is a good problem for practicing on neural
networks because all of the 4 input variables are numeric and have the same scale
in centimeters. Each instance describes the properties of an observed flower
measurements and the output variable is specific iris species.
This is a multi-class classification problem, meaning that there are more than two
classes to be predicted, in fact there are three flower species. This is an important
type of problem on which to practice with neural networks because the three
class values require specialized handling.
You can download the iris flowers dataset from the UCI Machine Learning
repository and place it in your current working directory with the filename
“iris.csv“.
REFER:https://machinelearningmastery.com/tutorial-first-neural-network-
python-keras/
https://github.com/fchollet/keras-resources