Book Image

Building Machine Learning Projects with TensorFlow

By : Rodolfo Bonnin
Book Image

Building Machine Learning Projects with TensorFlow

By: Rodolfo Bonnin

Overview of this book

<p>This book of projects highlights how TensorFlow can be used in different scenarios - this includes projects for training models, machine learning, deep learning, and working with various neural networks. Each project provides exciting and insightful exercises that will teach you how to use TensorFlow and show you how layers of data can be explored by working with Tensors. Simply pick a project that is in line with your environment and get stacks of information on how to implement TensorFlow in production.</p>
Table of Contents (16 chapters)
Building Machine Learning Projects with TensorFlow
Credits
About the Author
About the Reviewer
www.PacktPub.com
Preface

Example 2 - calculating Pi number in parallel


This example will serve as an introduction of parallel processing, implementing the Monte Carlo approximation of Pi.

Monte Carlo utilizes a random number sequence to perform an approximation.

In order to solve this problem, we will throw many random samples, knowing that the ratio of samples inside the circle over the ones on the square, is the same as the area ratio.

Random area calculation techniques

The calculation assumes that if the probability distribution is uniform, the number of samples assigned is proportional to the area of the figures.

We use the following proportion:

Area proportion for Pi calculation

From the aforementioned proportion, we infer that number of sample in the circle/number of sample of square is also 0.78.

An additional fact is that the more random samples we can generate for the calculation, the more approximate the answer. This is when incrementing the number of GPUs will give us more samples and accuracy.

A further reduction...