cover

83. Practice of Deep Learning Cloud Services#

83.1. Introduction#

In this experiment, we will introduce the cloud computing services commonly involved in the engineering applications of deep learning. You need to understand and try to apply these technologies to improve the efficiency of deep learning development and applications.

83.2. Key Points#

  • Deep learning computing platforms

  • Deep learning solutions

In the engineering application stage of deep learning, there is also something that has to be introduced: cloud services. Many years ago, every Internet company had its own computer room and servers. With the rise of PaaS (Platform As A Service) and SaaS (Software As A Service), cloud computing services have gradually been accepted and used.

At present, there are quite a few cloud services providing deep learning and machine learning related services. Among them, the major manufacturers available for individual users mainly include: Google Cloud, AWS, Microsoft Azure, Alibaba Cloud, Baidu Cloud, etc.

Although Google Cloud has industry-leading technologies in artificial intelligence, due to well-known reasons, it cannot be accessed normally in China. Therefore, in this experiment, we mainly select the cloud services related to deep learning provided by AWS abroad and Alibaba Cloud and Baidu Cloud in China for introduction.

It should be noted specifically that there is no commercial interest relationship between the cloud service products introduced and recommended in this experiment and the course production team. They are all tools or services that the team members often use.

83.3. AWS Abroad#

Image description

AWS is the abbreviation of Amazon Web Services. According to the data from Canalys, AWS is the cloud computing service provider with the largest global market share in recent years. The following table shows the market share and market growth of global cloud computing service providers in 2017 and 2018. Among them, AWS has stably occupied about 30% of the market share and maintained stable growth.

Currently, for deep learning, all cloud service providers mainly offer two major categories of products, which we summarize as: tools and services. Among them, tools refer to a series of products that can help developers complete deep learning, including cloud hosts, cloud GPUs, cloud-based Jupyter Notebooks, etc. Services, on the other hand, refer to existing APIs. Most service providers have good personnel and technical accumulations in deep learning methods and directly provide cloud interfaces that can be used for computer vision or natural language processing.

Of course, for tools, it is required that developers themselves master technologies related to deep learning. For services, developers only need to know how to call API interfaces and can completely lack deep learning skills.

83.3.1. AWS Deep Learning AMI#

AMI is the abbreviation of the environment image provided by AWS. AWS specifically provides a series of pre-configured environments for deep learning to facilitate the rapid construction of models. Currently, AWS Deep Learning AMI only provides environments for Amazon Linux and Ubuntu operating systems, and almost all common deep learning frameworks such as TensorFlow, PyTorch, Apache MXNet, Chainer, Microsoft Cognitive Toolkit, Gluon, Horovod, and Keras are pre-installed.

Simply put, you can start a cloud host with a pre-configured deep learning environment with one click, and this out-of-the-box experience is extremely convenient. For the detailed usage steps of AWS Deep Learning AMI, you can read Get Started with Deep Learning Using the AWS Deep Learning AMI.

83.3.2. Amazon SageMaker#

By default, AWS Deep Learning AMI only supports AWS EC2 cloud hosts, and the operating system it runs on is generally the Ubuntu server version, that is, there is no graphical interface. If you are not familiar with Linux, it may be rather uncomfortable to use. Amazon SageMaker, on the other hand, is a more targeted cloud computing service for deep learning, which can help developers quickly build, train, and deploy machine learning models.

https://cdn.aibydoing.com/aibydoing/images/uid214893-20190718-1563431601377.png

Simply put, Amazon SageMaker is a fully managed service that covers the entire machine learning workflow, including: labeling and preparing data, selecting algorithms, training models, tuning and optimizing for deployment, and model inference.

Most conveniently, Amazon SageMaker uses Jupyter Notebook by default, which should be the most familiar IDE for machine learning and data scientists. For a detailed introduction and usage instructions of Amazon SageMaker, you can read the relevant link.

Above, we introduced two very convenient cloud computing services launched by AWS for machine/deep learning. These two services are also frequently used by the course production team, being simple, easy to use, efficient, and convenient. However, it is worth noting that when you choose a GPU cloud host instance for computing, you must remember to delete the Amazon SageMaker instance after use, otherwise it may result in high costs.

83.3.3. AWS AI Service#

In addition to the tools provided for deep learning developers above, AWS also offers many ready-to-use APIs for direct invocation. For example, Amazon Comprehend is a natural language processing service that can be used to discover insights and relationships in text. Amazon Lex can be used to build voice and text chatbots. Amazon Rekognition can be used to analyze image or video content, including face recognition, object detection, etc. You can experience it through this link.

https://cdn.aibydoing.com/aibydoing/images/uid214893-20190718-1563433791545.png
{note}
Newly registered AWS accounts can get a certain free trial quota for the above services. For details, please refer to the [AWS Free Tier](https://amazonaws-china.com/cn/free) plan.

83.4. Domestic Cloud Services#

Although AWS is the world’s most popular cloud service, in many aspects, domestic cloud services such as Alibaba Cloud, Tencent Cloud, and Baidu Cloud seem to be more down-to-earth. For example, AWS provides general text detection and recognition services, while Alibaba Cloud provides more specific recognition services such as value-added tax invoice content recognition, taxi machine-printed invoice recognition, and ID card content recognition.

At the basic technical level, domestic cloud services also provide GPU cloud hosts, pre-configured images, etc., and there is not much difference in price from AWS and others, so it will not be elaborated here. If you are interested, you can visit the official websites of the corresponding cloud service providers to learn more by yourself.

On the service level, the API interfaces provided by domestic cloud service providers are more abundant, the prices are cheaper, and the calls are more convenient. Next, we will take Baidu Cloud as an example for introduction. The reason for choosing Baidu Cloud is that the products provided by domestic Alibaba Cloud, Tencent Cloud, and Baidu Cloud are relatively similar, and most services are also similar. Comparatively speaking, Baidu Cloud offers more free quotas and the SDK calls are more convenient. Therefore, Baidu Cloud is used as an example for this online experiment.

The official website of Baidu Cloud lists the products and services it offers, which are divided into two categories: applications and platforms, which are actually its corresponding SaaS and PaaS products. In terms of platforms, it is mainly supported by computing power. For example, BML is actually an online Jupyter Notebook model training service similar to Amazon SageMaker. In terms of applications, it is similar to AWS AI Service, but with more abundant interfaces provided.

https://cdn.aibydoing.com/aibydoing/images/uid214893-20190718-1563439067809.png

You can register for a free account to use a series of interfaces provided by Baidu Cloud. Next, we will try to complete some operations through the APIs provided by Baidu Cloud. Before that, we install the Python Development SDK provided by Baidu Cloud.

pip install baidu-aip  # 安装百度云 SDK

Next, you need to log in and select the service you need to obtain the API KEY. For example, we select Natural Speech Service and create an application. Check the types of interfaces you need to call, and finally you can generate the API KEY.

Next, we call the SDK and fill in the obtained key.

# 注册应用后会自动生成下方 3 个 KEY 信息
APP_ID = '16XX0141'
API_KEY = '0HUECBnXXXXo2EpiI8kqP5I'
SECRET_KEY = 'DdomRyxgwXXXXSlo1mroZu2YLN8jN'

Next, we will first demonstrate several applications related to natural speech processing. You can also read the official technical documentation. First, establish a client connection:

from aip import AipNlp

client = AipNlp(APP_ID, API_KEY, SECRET_KEY)
client

Currently, Baidu Cloud provides the following application interfaces related to natural language processing:

Interface Name Brief Description of Interface Capabilities
Lexical Analysis Word segmentation, part-of-speech tagging, proper name recognition
Dependency Parsing Automatically analyze the dependency syntactic structure information in the text
Word Vector Representation Query the word vectors of words and enable the computability of text
DNN Language Model Judge whether a sentence conforms to the language expression habit, output the word segmentation result and give the probability value of each word in the sentence
Word Sense Similarity Calculate the semantic similarity of two given words
Short Text Similarity Judge the similarity score of two texts
Comment Opinion Extraction Extract the emotional attribute of the opinion comment in a sentence
Sentiment Analysis Judge the sentiment polarity category (positive, negative, neutral) of the text containing subjective opinion information and give the corresponding confidence level
Chinese Word Segmentation Segment the basic vocabulary sequence in continuous text (merged into the lexical analysis interface)
Part-of-Speech Tagging Assign part-of-speech tags to each word in natural language text (merged into the lexical analysis interface)
News Summarization Automatically extract the key information in news text and then generate a news summary of a specified length

Sentiment analysis is a very common type of NLP application. The corresponding API judges the sentiment polarity category (positive, negative, neutral) of the text containing subjective opinion information and gives the corresponding confidence level.

text = "动手实战人工智能是一门不错的课程"

client.sentimentClassify(text)  # 调用情感倾向分析

In the returned data, sentiment represents the sentiment polarity classification result, confidence represents the confidence level of the classification, positive_prob represents the probability of belonging to the positive category, and negative_prob represents the probability of belonging to the negative category.

In addition, let’s try the text correction API, for example:

text = "动手实战人公智能是一门不错得课程"

data = client.ecnet(text)
print(f"纠错后:{data['item']['correct_query']}")
data

As can be seen, the ability to correct common words is quite good, and the typos are correctly corrected.

Since there are many NLP-related interfaces, we will not list them one by one here. You can refer to the official technical documentation according to your own ideas and interests. Here we have to mention a great advantage of domestic cloud services, that is, the official documentation is written in Chinese, which is more convenient for developers to use.

Next, we test some computer vision-related services. Currently, the image recognition-related interfaces provided by Baidu are:

Interface Name

Brief Description of Interface Capability

Image Subject Detection

Identify the specific coordinate positions of the subjects in the image.

General Object and Scene Recognition Advanced Edition

Identify the scene and object labels in the picture, supporting over 100,000 label types.

Dish Recognition

Detect the dish pictures uploaded by users and return the specific dish names, calories, and confidence information.

Custom Dish Recognition

Store custom single-dish pictures in the database to achieve accurate recognition of uploaded multi-dish pictures and return the specific dish names, positions, and confidence information.

LOGO Trademark Recognition

Identify the product LOGO information contained in the picture and return the LOGO brand name, position in the picture, and confidence.

Animal Recognition

Detect the animal pictures uploaded by users and return the animal names and confidence information.

Plant Recognition

Detect the plant pictures uploaded by users and return the plant names and confidence information.

Flower Recognition

Detect the flower pictures uploaded by users and return the flower names and confidence information.

Fruit and Vegetable Ingredient Recognition

Detect the fruit and vegetable pictures uploaded by users and return the fruit and vegetable names and confidence information.

Landmark Recognition

Detect the landmark pictures uploaded by users and return the landmark names.

Red Wine Recognition

Identify the red wine labels in the image and return information such as the red wine name, country, region, winery, type, sugar content, grape variety, and wine description.

Currency Recognition

Identify the currency type in the image and return information such as the currency name, code, face value, and year. It can recognize over a hundred common domestic and foreign currencies.

Experiment and test the dish recognition interface. According to its documentation, dish recognition can output the dish name, calorie information, and confidence level.

First, import a sample picture:

import requests
from PIL import Image
from io import BytesIO

# 请求网络图片
response = requests.get(
    'https://cdn.aibydoing.com/aibydoing/files/salad.jpeg')
image_raw = response.content
image = Image.open(BytesIO(image_raw))  # 读取为 PIL 对象可视化
image

The image recognition API can only accept image data and does not accept the above PIL object. Therefore, the input below is the image_raw variable.

from aip import AipImageClassify

client = AipImageClassify(APP_ID, API_KEY, SECRET_KEY)

client.dishDetect(image_raw)

The API will return the top 5 predicted categories by confidence level. If there is a Baidu Encyclopedia entry for the corresponding dish name, it will also be returned. Similarly, there is no need to list examples one by one here. You can try other image recognition interfaces according to your own interests.

83.5. Cloud Service Selection#

So far, we have introduced several commonly used cloud services at home and abroad. Regarding the platforms and interfaces involved in deep learning cloud services, we provide some suggestions on cloud service selection here, hoping to be helpful to you.

First of all, if you are choosing a training platform, such as a cloud host or a service that supports deep learning training, consider foreign services such as AWS first. The reason is that deep learning will definitely involve a lot of related resources and applications. For some tools, advanced pre-trained models are often hosted on external servers. Using hosts and services provided by foreign service providers such as AWS can effectively improve network quality. The download speed is fast and it is convenient to use, which can effectively avoid the situation where some resources cannot be accessed normally in China.

Secondly, services like AWS and Google Cloud are really good in this regard. For example, Amazon SageMaker. Although there are many imitators in China, it is very difficult to surpass it in terms of experience.

On the other hand, if you choose existing API interface services, give priority to domestic cloud service providers. The reason is that domestic service providers offer many more specialized interfaces that are convenient to call and inexpensive. Contrary to the above choice of platform, most of the services you develop are for domestic users, so naturally choosing domestic service providers will have a faster domestic connection speed.

Finally, let’s discuss another topic, that is: Since there are ready-made cloud services, why do we still need to learn relevant technologies by ourselves?

After completing this experiment, I believe many students have such a question. Since the ready-made API interfaces provided by cloud service providers are very good, then what’s the point of learning deep learning by ourselves? Indeed, for cloud service providers, they have a strong technical team, computing power, and dataset support, and generally, their commercial services are good. Many times, the models you train yourself are not as useful as directly calling the interfaces. However, these are only the advantages of cloud service providers.

Human creativity is irreplaceable. The services launched by cloud service providers are all commercially selected, and most of them are general-purpose and profitable services. However, these services cannot cover all needs. In the face of more specific scenarios, only engineers who understand technology can solve them.

83.6. Summary#

In this experiment, we introduced the common cloud computing providers related to deep learning and the services they offer. Under the wave of artificial intelligence, larger-scale cloud computing applications, serverless development, etc. have become new trends, and we need to understand and use these services and technologies. Of course, due to the rapid update and iteration of these technologies, you need to pay timely attention and try to apply them.


○ Sharethis article link to your social media, blog, forum, etc. More external links will increase the search engine ranking of this site.