Search icon
Arrow left icon
All Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Newsletters
Free Learning
Arrow right icon
Hands-On Deep Learning with TensorFlow

You're reading from  Hands-On Deep Learning with TensorFlow

Product type Book
Published in Jul 2017
Publisher Packt
ISBN-13 9781787282773
Pages 174 pages
Edition 1st Edition
Languages
Author (1):
Dan Van Boxel Dan Van Boxel
Profile icon Dan Van Boxel

Basic neural networks


Our logistic regression model worked well enough, but was fundamentally linear in nature. Doubling the intensity of a pixel doubled its contribution to the score, but we might only really care if a pixel was above a certain threshold or put more weight on changes to small values. Linearity may not capture all the nuances of the problem. One way to handle this issue is to transform our input with a nonlinear function. Let's look at a simple example in TensorFlow.

First, be sure to load the required modules (tensorflow, numpy, and math) and start an interactive session:

import tensorflow as tf
import numpy as np
import math

sess = tf.InteractiveSession()

In the following example, we create three five-long vectors of normal random numbers, truncated to keep them from being too extreme, with different centers:

x1 = tf.Variable(tf.truncated_normal([5],
                 mean=3, stddev=1./math.sqrt(5)))
x2 = tf.Variable(tf.truncated_normal([5],
                 mean=-1, stddev...
lock icon The rest of the chapter is locked
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $15.99/month. Cancel anytime}