PyTorch
PyTorch is an open source machine learning framework based on the Torch library, used for applications such as computer vision and natural language processing, primarily developed by Facebook's AI Research lab (FAIR). It is free and open-source software released under the Modified BSD license. Although the Python interface is more polished and the primary focus of development, PyTorch also has a C++ interface. A number of pieces of deep learning software are built on top of PyTorch, including Tesla Autopilot, Uber's Pyro, Hugging Face's Transformers, PyTorch Lightning, and Catalyst. PyTorch provides two high-level features : History. Facebook operates both "PyTorch" and "Convolutional Architecture for Fast Feature Embedding" (Caffe2), but models defined by the two frameworks were mutually incompatible. The Open Neural Network Exchange (ONNX) project was created by Facebook and Microsoft in September 2017 for converting models between frameworks. Caffe2 was merged into PyTorch at the end of March 2018. PyTorch tensors. PyTorch defines a class called Tensor (codice_1) to store and operate on homogeneous multidimensional rectangular arrays of numbers. PyTorch Tensors are similar to NumPy Arrays, but can also be operated on a CUDA-capable Nvidia GPU. PyTorch supports various sub-types of Tensors . Note that the term "tensor" here does not carry the same meaning as in mathematics or physics. The meaning of the word in those areas is only tangentially related to the one in Machine Learning. In mathematics, a tensor is a certain kind of object in linear algebra, while in physics the term "tensor" usually refers to what mathematicians call a tensor field. Modules. Autograd module. PyTorch uses a method called automatic differentiation. A recorder records what operations have performed, and then it replays it backward to compute the gradients. This method is especially powerful when building neural networks to  save time on one epoch by calculating differentiation of the parameters at the forward pass. codice_2 module. codice_3 is a module that implements various optimization algorithms used for building neural networks. Most of the commonly used methods are already supported, so there is no need to build them from scratch. codice_4 module. PyTorch autograd makes it easy to define computational graphs and take gradients, but raw autograd can be a bit too low-level for defining complex neural networks. This is where the codice_4 module can help. Example. The following program shows the functionality of the library with a simple  example import torch dtype = torch.float device = torch.device("cpu") # This executes all calculations on the CPU a = torch.randn(2, 3, device=device, dtype=dtype) print(a) # Output of tensor A b = torch.randn(2, 3, device=device, dtype=dtype) print(b) # Output of tensor B print(a*b) # Output of a multiplication of the two tensors print(a.sum()) # Output of the sum of all elements in tensor A print(a[1,2]) # Output of the element in the third column of the second row (zero based) print(a.max()) # Output of the maximum value in tensor A