Chapter 18.
Cloud Machine Learning Engine:
This chapter covers
What is machine learning?
What are neural networks?
What is TensorFlow?
What is Cloud ML Engine?
Creating and deploying your own ML model
Derive meaning from data
Volume of data passes the point humans can make sense of it
Automated systems can learn from the data and the changes in the data
To adapt to a shifting landscape
18.1. What is machine learning?
Simple definition
Machine learning teaches a computer to recognize patterns and make decisions by studying examples.
How it works
You give the computer data
(e.g., photos of cats and dogs, or past customer purchases).It finds patterns in the data
(e.g., cats usually have pointy ears; certain customers often buy certain products).It uses those patterns to make predictions
(e.g., “this picture looks like a cat” or “this customer may like product X”).
Machine learning and artificial intelligence are enormous topics with quite a lot of ongoing research.
ML APIs, such as the speech recognition example
System that can be trained with some data and then make predictions based on that training.
Different from how we typically build software.
The programmer translates that goal into explicit instructions or “rules” for the computer to follow.
Machine learning involves the idea of the computer figuring out the rules on its own rather than by having someone teach them explicitly.
Double a value, you’d take that goal (“multiply by two”) and write the program console.log(input * 2).
Machine learning, you’d instead show the system a bunch of inputs and desired outputs (such as 2 → 4 and 40 → 80), and using those examples, the system would be responsible for figuring out the rules on its own.
Make predictions about what 5 * 2 is without having seen that particular example before by assuming 5 is the input and making a prediction about 5 → ?.
Systems capable of “learning” using several methods.
Most interest recently is modeled after the human brain.
18.1.1. What are neural networks?
A neural network is a computational model inspired by the human brain, used in machine learning to recognize patterns in data. It consists of interconnected nodes or "neurons" organized in layers, which learn by processing data and adjusting the connections between neurons to improve predictions or classifications. The purpose of a neural network is to handle complex tasks like image and speech recognition that are difficult for traditional algorithms, through its ability to learn from data without being explicitly programmed
Fundamental components in modern machine learning systems are called a neural network.
All of the heavy lifting of both learning and predicting can vary in complexity from super simple.
A neural network is a directed graph containing a bunch of nodes.
Connected to one another along edges.
Each line has a certain weight.
The directed part means that things flow in a single direction.
Weights determine how much signal is transmitted into an output signal.
Value of one node affects the value of another node that it’s connected to.
Nodes themselves are organized into layers.
First layer accepting a set of input values.
Last layer representing a set of output values.
A neural network works by taking these input values and using the weights to pass those values from one layer to another.
Input can be manipulated bit by bit and end up completely different.
Where each node represents a person in the chain.
Weights on the edges between each node represent how well the next person can understand the previous person’s whispers.
Train a neural network by taking an input, sending it to get an output.
Adjusting weights on how far off the output was from the expected output.
Networks get good at making predictions for data that it hasn’t seen before.
Varying the weights between nodes throughout training.
Adjust values that are external to the training data.
Adjustments, called hyperparameters, used to tune the system for a specific problem to get the best predictive results.
Typically come from heuristics as well as trial and error.
The fundamental point, take input, look at output, and make adjustments.
18.2. What is a Cloud Machine Learning Engine?
Training machine-learning models can start out being pretty quick, but because it’s such a computationally intensive process, doing more iterations or using a more complex machine-learning model could end up taking quite a bit of time to compute.
Data will probably be customized to individual users and change over time as users do new things. As the data evolves, your machine-learning model should evolve as well, which would require that you retrain your model to get the most up-to-date predictions.
Demand for resources .
You need a lot of power to retrain the model,
Cloud Machine Learning Engine
('Simple model accuracy on test data:', 0.92510003)
Cloud Machine Learning Engine.
Acting as a hosted service for your machine-learning models that can provide infrastructure to handle storage, training, and prediction.
ML Engine can also store and host trained models so that you can send your inputs to ML Engine and request that a particular model be used to calculate the predicted outputs.
Send Cloud ML Engine something like your TensorFlow script, which you can use to train the model, and after that model is trained, you can send inputs to the model and get a prediction for what number was written.
ML Engine allows you to turn your custom models into something more similar to the other hosted machine-learning APIs like the Vision API.
18.2.1. Concepts
Core concepts that allow you to organize your project’s machine-learning pieces so that they’re easy to use and manage.
Cloud ML Engine is a bit like App Engine in that you can run arbitrary machine-learning code, but you can also organize the code into separate pieces, with different versions as things evolve over time.
Models
A machine-learning model is sort of like a black-box container that conforms to a specific interface that offers two primary functions: train and predict.
Training the model based on a chunk of labeled images and then attempts to get predictions from some images it hasn’t seen before.
Idea behind using machine learning is to find the answers that you don’t already know.
(train and predict) must exist.
Models are designed to ingest data of a specific format. If you were to send data of other formats to the model (either for training or predicting purposes), the results would be undefined.
Earlier script that recognizes handwritten numbers, the model is designed to understand input data in the form of a grayscale bitmap image of a handwritten number. If you were to send it data in any other format (such as a color image, a JPEG image, or anything else), any results would be meaningless.
If invalid data (such as an unknown image format) was the input during a prediction request, you’d likely see a bad guess for the number drawn or an error.
Invalid data during the training process, you’d likely reduce the overall accuracy because the model would be training itself on data that doesn’t make much sense.
The contract for the model you built previously could be thought of as the black box.
If the inputs or outputs change, the model itself is different, whereas if the model’s internal functionality fulfills the contract but uses different technology under the hood, the model may have different accuracy levels, but it still conceptually does the same job.
Jobs
Ability to be trained, ability to make predictions based on that training.
Amount of data involved in things like training can be exceptionally large.
A “job,” which is a way of requesting work be done asynchronously.
Some form of input that results in an output of the results, and it will run for as long as necessary to complete the work.
18.2.2. Putting it all together
ML Engine stores data in Cloud Storage.
The underlying data for that model lives in Google Cloud Storage.
ML Engine using jobs, so to get model data stored in Cloud Storage, you’d use a training job.
ML Engine to look for the training data somewhere in Cloud Storage.
Put the output job somewhere in Cloud Storage.
Upload the training data to Cloud Storage.
Create a job in ML Engine asking for that data to be used to train a version of your model.
Job (3) would take the training data from Cloud Storage and use it to train the new model version by running it through the model using the TensorFlow.
Store its output back on Cloud Storage so that you can use it for predicting.
End up with a trained model version in Cloud ML Engine with all the data needed being stored in Cloud Storage.
Ready to make predictions.
Start by uploading the data you want to make predictions on to Cloud Storage.
Create a new prediction job on ML Engine.
Specifying where your data is and which model to use to make the prediction.
When a prediction is ready, it’s sent to the job (5) and ultimately returned back to you (6) with all the details of what happened.
ML Engine aims to minimize the management work you’ll need to do to train and interact with models.
18.3. Interacting with Cloud ML Engine
Overview of US Census data
This data is also available to the public, and you can use some of it to make some interesting predictions.
Subset, which includes basic personal information including education and employment details.
Dataset will contain things like an individual’s age, employment situation (for example, private employer, government employer, and so on), level of education, marital status, race, income category (for example, less than or more than $50,000 annual income), and more. Some simplified rows are shown.
You can use all the other data in a row to train a model that can then make predictions about income category based on the other information.
Predict whether a person makes more than $50,000 in a year based on their age, employment status, marital status, and so on.
18.3.2. Creating a model
Model acts as a container of a prediction function that fulfills a specific contract
Model’s contract accepts rows of US Census data (with the income category field missing) as input and returns the predicted income category as output.
Using complete Census data to train your model to predict the income category field based on the rest of the row.
After training the model, you can then send it rows with the income category missing.
Send back predictions of the income category for that row.
The model is only a container, you can create it using the Cloud Console.
Summary
Machine learning is the overarching concept that you can train computers to perform a task using example data rather than explicitly programming them.
Neural networks are one method of training computers to perform tasks.
TensorFlow is an open source framework that makes it easy to express high-level machine-learning concepts (such as neural networks) in Python code.
Cloud Machine Learning Engine (ML Engine) is a hosted service for training and serving machine-learning models built with TensorFlow.
You can configure the underlying virtual hardware to be used in ML Engine, using either predefined tiers or more specific parameters (for example, machine types).
ML Engine charges based on hourly resource consumption (similar to other computing-focused services like Compute Engine) for both training and prediction jobs.
No comments:
Post a Comment