Skip to Content
Neural Network Projects with Python
book

Neural Network Projects with Python

by James Loy
February 2019
Beginner to intermediate
308 pages
7h 42m
English
Packt Publishing
Content preview from Neural Network Projects with Python

Feedforward

As we've seen in the preceding sequential graph, feedforward is just simple calculus, and for a basic two-layer neural network, the output of the neural network is as follows:

Let's add a feedforward function in our Python code to do exactly that. Note that for simplicity, we have assumed the biases to be 0:

import numpy as npdef sigmoid(x):    return 1.0/(1 + np.exp(-x))class NeuralNetwork:    def __init__(self, x, y):        self.input    = x        self.weights1 = np.random.rand(self.input.shape[1],4)         self.weights2 = np.random.rand(4,1)         self.y        = y        self.output   = np.zeros(self.y.shape)    def feedforward(self): self.layer1 = sigmoid(np.dot(self.input, ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Machine Learning with Python Cookbook

Machine Learning with Python Cookbook

Chris Albon

Publisher Resources

ISBN: 9781789138900Supplemental Content