深度学习库和计算框架_前5名深度学习库和框架

深度学习库和计算框架

深度学习(Deep Learning)

Deep learning is a branch of machine learning, in essence, its the implementation of neural networks with more than a single hidden layer of neurons.

深度学习是机器学习的一个分支,从本质上讲,它是神经网络的实现,具有多个神经元的单个隐藏层。

Image for post
AI, ML, DL (Pic credits: Pinterest)
AI,ML,DL(图片来源:Pinterest)

In this article, I’m going to cover the top 5 Deep Learning Libraries & Frameworks.

在本文中,我将介绍5个深度学习库和框架。

Here you go —

干得好 -

凯拉斯 (Keras)

Developed by François Chollet, a researcher at Google, Keras is a Python framework for deep learning.

由Google研究员FrançoisChollet开发的Keras是用于深度学习的Python框架。

Image for post

Keras has been used at organizations like Google, CERN, Yelp, Square, Netflix, and Uber. The advantage of Keras is that it uses the same Python code to run on CPU or GPU.

Keras已在Google,CERN,Yelp,Square,Netflix和Uber等组织中使用。 Keras的优点是它使用相同的Python代码在CPU或GPU上运行。

Keras models accept three types of inputs:

Keras模型接受三种类型的输入:

  • NumPy arrays, just like Scikit-Learn and many other Python-based libraries. This is a good option if your data fits in memory.

    NumPy数组,就像Scikit-Learn和许多其他基于Python的库一样。 如果您的数据适合内存,这是一个不错的选择。

  • TensorFlow Dataset objects. This is a high-performance option that is more suitable for datasets that do not fit in memory and that are streamed from disk or from a distributed filesystem.

    TensorFlow数据集对象。 这是一个高性能的选项,它更适用于内存不足且从磁盘或分布式文件系统流式传输的数据集。

  • Python generators that yield batches of data (custom subclasses of the keras.utils.Sequence class).

    生成大量数据的Python生成器( keras.utils.Sequence类的自定义子类)。

Keras features a range of utilities to help you turn raw data on disk into a Dataset:

K E特征的RAS功能,可以帮助您打开磁盘的原始数据到DataSet一系列的工具:

  • tf.keras.preprocessing.image_dataset_from_directory — It turns image files sorted into class-specific folders into a labeled dataset of image tensors.

    tf.keras.preprocessing.image_dataset_from_directory —将分类到特定于类的文件夹中的图像文件转换为带标签的图像张量数据集。

  • tf.keras.preprocessing.text_dataset_from_directory — It turns text files sorted into class-specific folders into a labeled dataset of text tensors.

    tf.keras.preprocessing.text_dataset_from_directory —将分类到特定于类的文件夹中的文本文件转换为带标签的文本张量数据集。

In Keras, layers are simple input-output transformations. For the preprocessing layers it includes:

在Keras中,层是简单的输入输出转换。 对于预处理层 包括:

  • Vectorizing raw strings of text via the TextVectorization layer

    通过TextVectorization层向量化文本的原始字符串

  • Feature normalization via the Normalization layer

    通过Normalization层进行特征归一Normalization

  • Image rescaling, cropping, or image data augmentation

    图像缩放,裁剪或图像数据扩充

Example —

示例-

from tensorflow.keras import layers# Center-crop images to 150x150
x = CenterCrop(height=150, width=150)(inputs)
# Rescale images to [0, 1]
x = Rescaling(scale=1.0 / 255)(x)# Apply some convolution and pooling layers
x = layers.Conv2D(filters=32, kernel_size=(3, 3), activation="relu")(x)
x = layers.MaxPooling2D(pool_size=(3, 3))(x)
x = layers.Conv2D(filters=32, kernel_size=(3, 3), activation="relu")(x)
x = layers.MaxPooling2D(pool_size=(3, 3))(x)
x = layers.Conv2D(filters=32, kernel_size=(3, 3), activation="relu")(x)# Apply global average pooling to get flat feature vectors
x = layers.GlobalAveragePooling2D()(x)# Add a dense classifier on top
num_classes = 10
outputs = layers.Dense(num_classes, activation="softmax")(x)

TensorFlow (TensorFlow)

Created by the Google Brain team, TensorFlow is an open-source library for numerical computation and large-scale machine learning.

由Google Brain团队创建的TensorFlow是一个用于数值计算和大规模机器学习的开源库。

Image for post

TensorFlow provides a collection of workflows to develop and train models using Python, JavaScript, or Swift, and to easily deploy in the cloud, on-premise, in the browser, or on-device irrespective of what language you use.

TensorFlow提供了一组工作流,以使用Python,JavaScript或Swift开发和训练模型,并且无论您使用哪种语言,都可以轻松地在云中,内部部署,浏览器或设备中进行部署。

Example —

示例-

import tensorflow as tf
mnist = tf.keras.datasets.mnist(x_train, y_train),(x_test, y_test) = mnist.load_data()
x_train, x_test = x_train / 255.0, x_test / 255.0model = tf.keras.models.Sequential([
tf.keras.layers.Flatten(input_shape=(28, 28)),
tf.keras.layers.Dense(128, activation='relu'),
tf.keras.layers.Dropout(0.2),
tf.keras.layers.Dense(10, activation='softmax')
])model.compile(optimizer='adam',
loss='sparse_categorical_crossentropy',
metrics=['accuracy'])model.fit(x_train, y_train, epochs=5)
model.evaluate(x_test, y_test)

The tf.data API enables you to build complex input pipelines from simple, reusable pieces. TensorFlow can train and run deep neural networks for handwritten digit classification, image recognition, word embeddings, recurrent neural networks, sequence-to-sequence models for machine translation, natural language processing, and PDE (partial differential equation) based simulations. TensorFlow allows developers to create dataflow graphs — structures that describe how data moves through a graph, or a series of processing nodes. Each node in the graph represents a mathematical operation, and each connection or edge between nodes is a multidimensional data array or tensor.

使用tf.data API,您可以从简单,可重用的片段中构建复杂的输入管道。 TensorFlow可以训练和运行用于手写数字分类,图像识别,单词嵌入,递归神经网络,用于机器翻译的序列到序列模型,自然语言处理以及基于PDE(偏微分方程)的深度神经网络。 TensorFlow允许开发人员创建数据流图-描述数据如何通过图或一系列处理节点移动的结构。 图中的每个节点表示一个数学运算,节点之间的每个连接或边都是多维数据数组或张量。

TensorFlow provides an abstraction for machine learning development.

TensorFlow为机器学习开发提供了一种抽象

咖啡 (Caffe)

Caffe is written in C++ and can perform computation on both CPU and GPU. The primary uses of Caffe are Convolutional Neural Network (CNN).

Caffe用C ++编写,可以在CPU和GPU上执行计算。 Caffe的主要用途是卷积神经网络(CNN)。

Image for post

It is known for —

它以-

  • Speed makes Caffe perfect for research experiments and industry deployment. Caffe can process over 60M images per day with a single NVIDIA K40 GPU.

    速度使Caffe成为研究实验和行业部署的理想选择。 Caffe单个NVIDIA K40 GPU每天可处理超过6000万张图像。
  • Expressive architecture — Models and optimization are defined by configuration without hard-coding. Switch between CPU and GPU by setting a single flag to train on a GPU machine then deploy to commodity clusters or mobile devices.

    富有表现力的体系结构—模型和优化是通过配置定义的,而无需硬编码。 通过设置单个标志在GPU机器上进行训练,然后部署到商品集群或移动设备,在CPU和GPU之间切换。

  • Extensible code by active development.

    通过积极开发可扩展代码。
  • Modularity: new tasks and settings require flexibility and extension.

    模块化:新的任务和设置需要灵活性和扩展性。
  • Openness: scientific and applied progress call for common code, reference models, and reproducibility.

    开放性:科学和应用的进步要求通用代码,参考模型和可重复性。
  • Community: academic research, startup prototypes etc

    社区:学术研究,创业原型等

茶野(Theano)

Theano is a Python library that allows you to define, optimize, and evaluate mathematical expressions involving multi-dimensional arrays efficiently, featuring tight integration with NumPy, transparent use of a GPU, efficient symbolic differentiation, speed, and stability optimizations and dynamic C code generation.

Theano是一个Python库,可让您有效地定义,优化和评估涉及多维数组的数学表达式,并具有与NumPy的紧密集成,GPU的透明使用,高效的符号微分,速度和稳定性优化以及动态C代码生成的功能。

Image for post

Its advantages include —

它的优势包括-

  • Symbolic Differentiation: Theano creates symbolic graphs for computing gradients automatically.

    符号区分:Theano创建用于自动计算梯度的符号图。
  • Stability Optimization — It can find out some unstable expressions and can use more stable means to evaluate them

    稳定性优化-它可以找出一些不稳定的表达式,并可以使用更稳定的方法对其进行评估
  • Efficient code — It knows how to take structures and convert them into very efficient code that uses NumPy and some native libraries. Theano is designed to handle the types of computation required for large neural network algorithms used in Deep Learning.

    高效代码—它知道如何采用结构并将其转换为使用NumPy和某些本机库的高效代码。 Theano旨在处理深度学习中使用的大型神经网络算法所需的计算类型。
  • Execution Speed Optimization — It can make use of recent GPUs and execute parts of expressions in your CPU or GPU, making it much faster than Python

    执行速度优化-它可以利用最新的GPU并在您的CPU或GPU中执行部分表达式,使其比Python快得多

示例-(Example —)

import theano 
from theano import tensor
x = tensor.dscalar()
y = tensor.dscalar()
z = x * y
f = theano.function([x,y], z)
print(f(6.2, 7.1))

Logistic Function —

物流功能—

# Python program to illustrate logistic 
# sigmoid function using theano
# Load theano libraryimport theano
from theano import tensor# Declaring variable
a = tensor.dmatrix('a')# Sigmoid function
sig = 1 / (1 + tensor.exp(-a))# Now it takes matrix as parameters
log = theano.function([a], sig)# Calling function
print(log([[0, 1], [-3, -4]]))

MXNet (MXNet)

Apache MXNet is a deep learning framework designed for both efficiency and flexibility which is accessible with multiple programming languages including C++, Julia, Python, and R.

Apache MXNet是一个旨在提高效率和灵活性的深度学习框架,可通过多种编程语言(包括C ++,Julia,Python和R)进行访问。

Image for post

Some of its features include —

它的某些功能包括-

  • Flexible configuration for arbitrary computation graph

    灵活配置任意计算图
  • Mix and match imperative and symbolic programming to maximize flexibility and efficiency

    混合和匹配命令性和符号编程,以最大程度地提高灵活性和效率
  • Lightweight, memory efficient and portable to smart devices

    轻巧,内存高效且可移植到智能设备
  • Scales up to multi GPUs and distributed setting with auto parallelism

    通过自动并行扩展到多GPU和分布式设置

At its core, MXNet contains a dynamic dependency scheduler that automatically parallelizes both symbolic and imperative operations on the fly.MXNet includes state-of-the-art deep learning architecture such as Convolutional Neural Network(CNN) and Long Short-Term Memory(LSTM).MXNet’s Gluon library provides a high-level interface that makes it easy to prototype, train, and deploy deep learning models without sacrificing training speed. Gluon offers high-level abstractions for predefined layers, loss functions, and optimizers. It also provides a flexible structure that is intuitive to work with and easy to debug. MXNet supports a broad set of programming languages — including C++, JavaScript, Python, R, Matlab, Julia, Scala, Clojure, and Perl — so you can get started with languages that you already know. On the backend, however, all code is compiled in C++ for the greatest performance regardless of what language is used to build the models.

MXNet的核心是动态依赖项调度程序,可自动并行化符号和命令式操作.MXNet包括最新的深度学习架构,例如卷积神经网络(CNN)和长短期记忆(LSTM) ).MXNet的Gluon库提供了一个高级接口,可以轻松进行深度学习模型的原型设计,训练和部署,而无需牺牲训练速度。 Gluon为预定义的层,损失函数和优化器提供了高级抽象。 它还提供了一种灵活的结构,该结构直观易用且易于调试。 MXNet支持广泛的编程语言集,包括C ++,JavaScript,Python,R,Matlab,Julia,Scala,Clojure和Perl,因此您可以开始使用已经知道的语言。 但是,在后端,无论使用哪种语言来构建模型,所有代码均以C ++编译以实现最佳性能。

References and credits —

参考和鸣谢—

翻译自: https://medium.com/ai-in-plain-english/the-top-5-deep-learning-libraries-and-frameworks-dfc7f3a492ec

深度学习库和计算框架

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值