Pytorch 简介

PyTorch的由来

很多人都会拿PyTorch和Google的Tensorflow进行比较,这个肯定是没有问题的,因为他们是最火的两个深度学习框架了。但是说到PyTorch,其实应该先说Torch

Torch是什么?

Torch英译中:火炬

A Tensor library like Numpy, unlike Numpy it has strong GPU support. Lua is a wrapper for Torch (Yes! you need to have a good understanding of Lua), and for that you will need LuaRocks package manager.

Torch是一个与Numpy类似的张量(Tensor)操作库,与Numpy不同的是Torch对GPU支持的很好,Lua是Torch。[1]

Torch is not going anywhere. PyTorch and Torch use the same C libraries that contain all the performance: TH, THC, THNN, THCUNN and they will continue to be shared.
We still and will have continued engineering on Torch itself, and we have no immediate plan to remove that.

PyTorch和Torch使用包含所有相同性能的C库:TH, THC, THNN, THCUNN,并且它们将继续共享这些库。
这样的回答就很明确了,其实PyTorch和Torch都使用的是相同的底层,只是使用了不同的上层包装语言。
LUA虽然快,但是太小众了,所以才会有PyTorch的出现。[2]

重新介绍 PyTorch

PyTorch is an open source machine learning library for Python, based on Torch, used for applications such as natural language processing. It is primarily developed by Facebook's artificial-intelligence research group, and Uber's "Pyro" software for probabilistic programming is built on it.

PyTorch是一个基于Torch的Python开源机器学习库,用于自然语言处理等应用程序。 它主要由Facebook的人工智能研究小组开发。Uber的"Pyro"也是使用的这个库。[3]

PyTorch is a Python package that provides two high-level features:
- Tensor computation (like NumPy) with strong GPU acceleration
- Deep neural networks built on a tape-based autograd system

You can reuse your favorite Python packages such as NumPy, SciPy and Cython to extend PyTorch when needed.

PyTorch是一个Python包,提供两个高级功能: * 具有强大的GPU加速的张量计算(如NumPy) * 包含自动求导系统的的深度神经网络

任何时候,你可以用你喜欢的Python包,如NumPy、SciPy 和 Cython去扩展PyTorch。[4]

对比PyTorch和Tensorflow

没有好的框架,只有合适的框架, 这篇知乎文章有个简单的对比,2019年6月25日[机器之心]翻译的PyTorch和Keras的最新对比,所以这里就不详细再说了。 并且技术是发展的,知乎上的对比也不是绝对的,比如Tensorflow在1.5版的时候就引入了Eager Execution机制实现了动态图,PyTorch的可视化,windows支持,沿维翻转张量等问题都已经不是问题了。

再次总结