Posted by Kaz Sato, Staff Developer Advocate, Google Cloud Platform
If you’ve ever learned to program, you’ve probably written a Fizz Buzz test. With Fizz Buzz, you print the numbers from 1 to 100, except if it is divisible by 3, you print "fizz"; if it’s divisible by 5, you print "buzz"; and if it’s divisible by 15 you print "fizzbuzz." This trivial coding problem is typically achieved with a couple of if statements and checking whether each number can be divided by 3 or 5.
Not if you’re Joel Grus, software engineer and data scientist (and former Googler). In his recent blog post " Fizz Buzz in TensorFlow ," Grus imagines he’s asked to solve Fizz Buzz as part of a job interview. But instead of taking the obvious approach, he uses TensorFlow, the open-source machine learning library developed by Google.
This is where things get funny.
interviewer: Do you need help getting started?
me: No, no, I’m good. So let’s start with some standard imports:
import <strong>numpy</strong> as np<br /> import <strong>tensorflow</strong> as tf
interviewer: Um, you understand the problem is fizzbuzz, right?
me: Do I ever. So, now let’s talk models. I’m thinking a simple multi-layer-perceptron with one hidden
Why use NumPy , the popular Python library for scientific computing, and TensorFlow? Because Grus is building a multi-layer perceptron — a neural network — to let the computer learn from the training data set (the actual Fizz Buzz results) and let it predict whether you’ll get Fizz or Buzz for each number.
What’s the end result? Check out the full post for details on how Grus builds a simple neural network with TensorFlow to predict FizzBuzz numbers. Along the way, you’ll learn how to apply machine learning techniques to solve even the simplest of problems, not just AI-ish problems such as image and voice recognition.
Although solving FizzBuzz in TensorFlow doesn’t end up being the best solution (Jeff Deanrecommends using more sophisticated algorithms — ha ha), it’s still a cool story that shows the essential difference between letting humans solve a problem vs. letting computers solve it.
转载本站任何文章请注明：转载至神刀安全网，谢谢神刀安全网 » The (fizz) buzz around TensorFlow and machine learning