caffe2 caffe_Caffe2-快速指南

caffe2 caffe

caffe2 caffe

Caffe2-快速指南 (Caffe2 - Quick Guide)

Caffe2-简介 (Caffe2 - Introduction)

Last couple of years, Deep Learning has become a big trend in Machine Learning. It has been successfully applied to solve previously unsolvable problems in Vision, Speech Recognition and Natural Language Processing (NLP). There are many more domains in which Deep Learning is being applied and has shown its usefulness.

最近几年,深度学习已成为机器学习的一大趋势。 它已成功应用于解决视觉,语音识别和自然语言处理 (NLP)中以前无法解决的问题。 深度学习正被应用到更多领域,并显示出其有用性。

Caffe (Convolutional Architecture for Fast Feature Embedding) is a deep learning framework developed at Berkeley Vision and Learning Center (BVLC). The Caffe project was created by Yangqing Jia during his Ph.D. at University of California - Berkeley. Caffe provides an easy way to experiment with deep learning. It is written in C++ and provides bindings for Python and Matlab.

Caffe(用于快速特征嵌入的卷积体系结构)是由伯克利视觉与学习中心(BVLC)开发的深度学习框架。 Caffe项目由贾庆清博士期间创建。 在加州大学伯克利分校就读。 Caffe提供了一种进行深度学习实验的简便方法。 它是用C ++编写的,并提供了PythonMatlab的绑定。

It supports many different types of deep learning architectures such as CNN (Convolutional Neural Network), LSTM (Long Short Term Memory) and FC (Fully Connected). It supports GPU and is thus, ideally suited for production environments involving deep neural networks. It also supports CPU-based kernel libraries such as NVIDIA, CUDA Deep Neural Network library (cuDNN) and Intel Math Kernel Library (Intel MKL).

它支持许多不同类型的深度学习架构,例如CNN (卷积神经网络), LSTM (长短期记忆)和FC(全连接)。 它支持GPU,因此非常适合涉及深度神经网络的生产环境。 它还支持基于CPU的内核库,例如NVIDIA ,CUDA深度神经网络库(cuDNN)和英特尔数学内核库(Intel MKL)

In April 2017, U.S. based social networking service company Facebook announced Caffe2, which now includes RNN (Recurrent Neural Networks) and in March 2018, Caffe2 was merged into PyTorch. Caffe2 creators and community members have created models for solving various problems. These models are available to the public as pre-trained models. Caffe2 helps the creators in using these models and creating one’s own network for making predictions on the dataset.

2017年4月,美国社交网络服务公司Facebook宣布Caffe2,现在包括RNN(递归神经网络),2018年3月,Caffe2合并为PyTorch。 Caffe2的创建者和社区成员创建了用于解决各种问题的模型。 这些模型作为预训练模型可供公众使用。 Caffe2帮助创建者使用这些模型并创建自己的网络以对数据集进行预测。

Before we go into the details of Caffe2, let us understand the difference between machine learning and deep learning. This is necessary to understand how models are created and used in Caffe2.

在详细介绍Caffe2之前,让我们了解机器学习深度学习之间的区别。 这对于了解如何在Caffe2中创建和使用模型是必要的。

机器学习与深度学习 (Machine Learning v/s Deep Learning)

In any machine learning algorithm, be it a traditional one or a deep learning one, the selection of features in the dataset plays an extremely important role in getting the desired prediction accuracy. In traditional machine learning techniques, the feature selection is done mostly by human inspection, judgement and deep domain knowledge. Sometimes, you may seek help from a few tested algorithms for feature selection.

在任何机器学习算法中,无论是传统算法还是深度学习算法,数据集中特征的选择对于获得所需的预测精度都起着极其重要的作用。 在传统的机器学习技术中, 特征选择主要是通过人工检查,判断和深层知识来完成的。 有时,您可能会从一些经过测试的算法中寻求帮助以进行功能选择。

The traditional machine learning flow is depicted in the figure below −

下图描述了传统的机器学习流程-

Machine Learning

In deep learning, the feature selection is automatic and is a part of deep learning algorithm itself. This is shown in the figure below −

在深度学习中,特征选择是自动的,并且是深度学习算法本身的一部分。 如下图所示:

Deep Learning

In deep learning algorithms, feature engineering is done automatically. Generally, feature engineering is time-consuming and requires a good expertise in domain. To implement the automatic feature extraction, the deep learning algorithms typically ask for huge amount of data, so if you have only thousands and tens of thousands of data points, the deep learning technique may fail to give you satisfactory results.

在深度学习算法中, 特征工程是自动完成的。 通常,要素工程非常耗时,并且需要在领域内具有良好的专业知识。 为了实现自动特征提取,深度学习算法通常需要大量数据,因此,如果您只有成千上万的数据点,则深度学习技术可能无法为您提供令人满意的结果。

With larger data, the deep learning algorithms produce better results compared to traditional ML algorithms with an added advantage of less or no feature engineering.

与传统的机器学习算法相比,有了更大的数据,深度学习算法可产生更好的结果,并具有更少或不需要特征工程的优势。

Caffe2-概述 (Caffe2 - Overview)

Now, as you have got some insights into deep learning, let us get an overview of what is Caffe.

现在,当您对深度学习有了一些了解时,让我们大致了解一下Caffe。

训练CNN (Training a CNN)

Let us learn the process for training a CNN for classifying images. The process consists of the following steps −

让我们学习训练CNN对图像进行分类的过程。 该过程包括以下步骤-

  • Data Preparation − In this step, we center-crop the images and resize them so that all images for training and testing would be of the same size. This is usually done by running a small Python script on the image data.

    数据准备 -在此步骤中,我们对图像进行中心裁剪并调整其大小,以便用于训练和测试的所有图像都具有相同的大小。 这通常是通过在图像数据上运行一个小的Python脚本来完成的。

  • Model Definition − In this step, we define a CNN architecture. The configuration is stored in .pb (protobuf) file. A typical CNN architecture is shown in figure below.

    模型定义 -在这一步,我们定义一个CNN体系结构。 配置存储在.pb(protobuf)文件中。 下图显示了典型的CNN架构。

  • Solver Definition − We define the solver configuration file. Solver does the model optimization.

    求解器定义 -我们定义求解器配置文件。 求解器进行模型优化。

  • Model Training − We use the built-in Caffe utility to train the model. The training may take a considerable amount of time and CPU usage. After the training is completed, Caffe stores the model in a file, which can later on be used on test data and final deployment for predictions.

    模型训练 -我们使用内置的Caffe实用程序来训练模型。 培训可能会花费大量时间和CPU使用率。 训练完成后,Caffe将模型存储在文件中,以后可用于测试数据和最终部署以进行预测。

Training CNN

Caffe2的新增功能 (What’s New in Caffe2)

In Caffe2, you would find many ready-to-use pre-trained models and also leverage the community contributions of new models and algorithms quite frequently. The models that you create can scale up easily using the GPU power in the cloud and also can be brought down to the use of masses on mobile with its cross-platform libraries.

在Caffe2中,您会发现许多现成的预训练模型,并且还经常利用新模型和算法对社区的贡献。 您创建的模型可以使用云中的GPU功能轻松扩展,也可以归因于其跨平台库在移动设备上的大量使用。

The improvements made in Caffe2 over Caffe may be summarized as follows −

与Caffe相比,Caffe2所做的改进可总结如下-

  • Mobile deployment

    移动部署
  • New hardware support

    新硬件支持
  • Support for large-scale distributed training

    支持大规模的分布式培训
  • Quantized computation

    量化计算
  • Stress tested on Facebook

    在Facebook上进行压力测试

预训练模型演示 (Pretrained Model Demo)

The Berkeley Vision and Learning Center (BVLC) site provides demos of their pre- trained networks. One such network for image classification is available on the link stated herewith https://caffe2.ai/docs/learn-more#null__caffe-neural-network-for-image-classification and is depicted in the screenshot below.

伯克利视觉与学习中心(BVLC)站点提供了其预训练网络的演示。 可以在https://caffe2.ai/docs/learn-more#null__caffe-neural-network-for-image-classification所述的链接上找到一种此类图像分类网络,并在下面的屏幕快照中进行了描述。

Pretrained Model

In the screenshot, the image of a dog is classified and labelled with its prediction accuracy. It also says that it took just 0.068 seconds to classify the image. You may try an image of your own choice by specifying the image URL or uploading the image itself in the options given at the bottom of the screen.

在屏幕截图中,对狗的图像进行了分类并以其预测准确性进行了标记。 它还说,仅需0.068秒即可对图像进行分类。 您可以通过指定图像网址或在屏幕底部提供的选项中上传图像本身来尝试自己选择的图像。

Caffe2-安装 (Caffe2 - Installation)

Now, that you have got enough insights on the capabilities of Caffe2, it is time to experiment Caffe2 on your own. To use the pre-trained models or to develop your models in your own Python code, you must first install Caffe2 on your machine.

现在,您已经对Caffe2的功能有了足够的了解,现在该是您自己尝试Caffe2的时候了。 要使用经过预训练的模型或以自己的Python代码开发模型,必须首先在计算机上安装Caffe2。

On the installation page of Caffe2 site which is available at the link https://caffe2.ai/docs/getting-started.html you would see the following to select your platform and install type.

在Caffe2站点的安装页面上,该页面可通过链接https://caffe2.ai/docs/getting-started.html获得,您将看到以下内容以选择平台和安装类型。

Installation Page

As you can see in the above screenshot, Caffe2 supports several popular platforms including the mobile ones.

从上面的屏幕截图中可以看到, Caffe2支持包括移动平台在内的几种流行平台。

Now, we shall understand the steps for MacOS installation on which all the projects in this tutorial are tested.

现在,我们将了解MacOS安装步骤,本教程中的所有项目均已在该步骤上进行了测试。

MacOS安装 (MacOS Installation)

The installation can be of four types as given below −

安装可以分为以下四种类型-

  • Pre-Built Binaries

    预编译二进制
  • Build From Source

    从源构建
  • Docker Images

    Docker映像
  • Cloud

Depending upon your preference, select any of

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值