Python is not perfect, Swift is growing into deep learning language

"Life is short, I am. With Python," but in Python flourishing today, and may require deep learning a new programming language. Machine Learning Engineer Max Pechyonkin think Swift is likely to become an important depth of learning the language, he briefly describes the advantages and prospects of Swift in a blog post. You will learn Swift consider it?

Python is not perfect, Swift is growing into deep learning language

 

If you know how to program, when they hear Swift, you might think of an application for iOS or MacOS development. If you understand the depth of learning, then you certainly heard of Swift for Tensorflow (referred S4TF): https: //www.tensorflow.org/swift. So you may be asking yourself: "Why Google Swift To create a TensorFlow version of it, after all, already have Python and C ++ version; why add a language??" I will try to answer this question in this article, and will you should pay serious attention to the reasons listed S4TF and Swift language itself. The purpose of this paper is not an exhaustive explanation, but to provide a general overview, the paper also with a large number of links to help you better understand the depth of the ground.

There is strong support behind Swift

Swift was created by Chris Lattner at work Apple. Now, Chris Lattner in Google brain works, and Google brain is one of the world's best artificial intelligence team. Swift creator of the language is now a research laboratory working depth study, which is sufficient to show that the project is serious.

Some time ago, Google people realize that, even if the Python language very well, and there are still some limitations to overcome. TensorFlow need a new language. After a long period of discretion, Swift became a candidate. I'm not here to talk about the details, but here's a document describing the defect Python and other languages ​​to be considered, but also explain why eventually narrowed it down to the Swift: https: //github.com/tensorflow/swift/blob/ master / docs / WhySwiftForTensorFlow.md

Swift for TensorFlow not just a software library

Swift for TensorFlow TensorFlow not just another language. Swift is another branch of the language itself, its essence. In other words, S4TF not just a software library; it means one language itself, which built all the functions needed to support TensorFlow. For example, S4TF comes with a very powerful automatic differentiation system, which is one of the depth of learning required in the calculation of the gradient function basis. Compare Python-- automatic differentiation is not a core component of the language. After S4TF in some newly developed feature is also integrated into the Swift language.

Swift fast

When I first learned that Swift's speed and as fast as C code, I was shocked. I know C language is highly optimized to achieve a very high speed, but the memory is required micro-management (which makes the C language does not guarantee the security of memory). In addition, C language is also very easy to learn.

Now, Swift in terms of numerical operations as fast as C language, but also no memory security issues, the learning curve is much lower. LLVM Swift behind the very powerful, can be very efficient optimization, which ensures high-speed run your code.

You can use Python, C and C ++ code in Swift

Because Swift for machine learning is still in its very early stages, so the current machine learning library for Swift is not much. But you do not have to worry too much about this because Swift Python interpreter with outstanding ability. You can directly import any Python library Swift for use. Similarly, you can import the C and C ++ libraries Swift (for C ++, you want to make sure that the header files are written in C, not C ++ features).

In general, if you need a specific function, but Swift has not been implemented, then you can import the corresponding Python, C or C ++ package. very impressive!

Swift can do very low-level

If you used TensorFlow, then you are likely to be used by Python. Under the surface, the following Python version of TensorFlow library is C code. So when you call any function TensorFlow in, you will encounter at some level C code. This means that if you want to check the source code level you can reach is very limited. For example, if you want to see the implementation of convolution, then you will not see Python code written for this purpose, because it is written in C language.

Swift is not the same. Chris Lattner the Swift called "LLVM (assembly language) syntactic candy (https://www.fast.ai/2019/03/06/fastai-swift/)." Very close to the hardware on which means Swift essence, during which no use other layers of code written in C language. This also means that Swift code is very fast, as mentioned earlier. This feature allows developers to not only check the code on a very high level, it can penetrate a very low level, but without involving the C language.

Swift's future development

Swift is only part of Google innovation in the field of deep learning. There is also a very relevant components: MLIR: https: //medium.com/tensorflow/mlir-a-new-intermediate-representation-and-compiler-framework-beba999ed18d. MLIR called the Multi-Level Intermediate Representation, i.e., multi-level intermediate representation. MLIR will become Google's unified compiler infrastructure, so that developers can write code in Swift (or any other language support), and then compile it to any supported hardware. Currently, there are many different compilers for different target hardware, and MLIR will change this situation. This not only allows reuse of code to achieve, but also allows developers to write custom compiler for low-level components. It also allows researchers apply machine learning to optimize low-level algorithms:

Although MLIR is used as a machine learning compiler, we also see that it can be applied machine learning techniques implemented in the internal compiler! This is especially important because engineers developed numerical libraries grow as fast as the speed of the machine learning model or hardware diversity.

Imagine, if you can use depth study based on data to help optimize memory fragmentation algorithm lower level (which is the language you want Halide functions implemented), what will happen? For more information about Halide language: https: //www.youtube.com/watch v = 3uiEyEKji0M?. This is just the beginning, in the application of machine learning compiler more creative is on the way!

Guess you like

Origin blog.csdn.net/java276582434/article/details/91444800