Understanding TensorFlow Using Go__go

Source: Internet
Author: User
Tags gopher

TensorFlow is not a Machine Learning specific library, instead, are a general purpose computation library that represent s computations with graphs. Its core are implemented in C + + and there are also bindings for different languages. The bindings for the "Go" programming language, differently from the Python ones, are a useful tool Rflow in Go but also for understanding how TensorFlow is implemented under the hood. the Bindings

Officially, the TensorFlow ' s developers released:the C + + source Code:the Real TensorFlow core where the high & low L Evel operations are concretely implemented. The Python bindings & the Python library:the bindings are automatically generated from the C + + implementation, in thi S way we can use Python to invoke C + + Functions:that ' s How, for instance, the core of NumPy is implemented. The library, moreover, combines calls to the bindings in order to define the higher level API that everyone ' s using Tensor Flow knows. The Java bindings The go Binding

Being a Gopher and not a Java lover, I started looking at the "Go bindings in" to "understand what kind of tasks they w Ere created for. The Go bindings

The Gopher (created by Takuya Ueda (@tenntenn). Licensed under the Creative Commons 3.0 attributions)
Overlapping the TensorFlow Logo.

The the "thing" to "the" Go API, for admission of the maintainers itself, lacks the Variable support:this API is designed to use trained the models and not for trainingmodels from scratch. This is clearly stated in the installing TensorFlow as go:

TensorFlow provides APIs for use in the Go programs. These APIs are particularly well-suited to loading models created in Python and executing them within a go application.

If we ' re not interested in training ML models:hooray! If, instead, you ' re interested into training models here's an advice:

Be a real gopher, keep it simple! Use Python to define & train models; Can always load trained models and using them with Go later!

In short:the go bindings can is used to import and define constants graphs; Where constant, in the, means that there ' s no training process involved and thus no trainable variables.

Let's now start diving into the tensorflow using Go:let ' s create our we-a-application.

In the following, I suppose which reader has its go environment ready and the TensorFlow bindings compiled and Installe D as explained in the README. Understand TensorFlow structure

Let ' s repeat what TensorFlow are (kept from TensorFlow website, the emphasis is mine):

Tensorflow™is an open source software the library for numerical computation the Using Data flow graphs. Nodes in the graph represent mathematical operations, while the graph edges represent the multidimension Al data Arrays (tensors) communicated between them.

We can do tensorflow as a descriptive language, a bit like SQL, in which you describe what you want and let the Unde Rlying engine (the database) parse your query, check for syntactic and semantic errors, convert it to its private represen Tation, optimize it and compute the Results:all this to give your correct results.

Therefore, what we really do if we use any of the available APIs are to describe a graph:the evaluation of the graph STA RTS when we are it into a session and explicitly decide to Run the graph within the session.

Knowing this, let's try to define a computational graph and evaluate it within a session. The API documentation gives us a pretty clear list of the available methods within the Packages TensorFlow (shorthanded TF ) & Op.

As we can, these two packages contains everything we need to define and evaluate a graph.

The former contains the functions to construct the basic "empty" structures like the Graph itself, the latter is the most Important package that contains the bindings automatically generated to the "C + + implementation."

However, suppose that we want to compute the matrix multiplication between a A and X where A= (1−12−2), x= (

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.