09.10.2023 Views

Advanced Data Analytics Using Python_ With Machine Learning, Deep Learning and NLP Examples ( 2023)

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Chapter 5

Deep Learning and Neural Networks

Calculate the outputs.

o f o net

o

pk

=

k ( pk )

Calculate the error terms for the output units.

o

d pk

o’

( y o

pk

opk ) fk

( net

pk )

= -

Calculate the error terms for the hidden units.

d

h h ’ h o

pj

= fj

( netpj

)ådpk

k

w

o

kj

Update weights on the output layer.

( )= ()+

o

wkj

w o

o

t+

1

kj

t hd

pki pj

Update weights on the hidden layer.

( )= ()+

h

wji

w h

h

t+

1

ji

t hd

pj

x i

Backpropagation Algorithm

Let’s see some code:

class NeuralNetwork(object):

def backpropagate(self,x,y):

"""Return a tuple "(nabla_b, nabla_w)"

representing the

gradient for the cost function C_x. "nabla_b" and

"nabla_w" are layer-by-layer lists of numpy

arrays, similar

104

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!