Theano Study Notes (3)-graph structure, theano Study Notes

Source: Internet
Author: User
Tags theano

Theano Study Notes (3)-graph structure, theano Study Notes

Graph ures is the basis for understanding Theano's internal working principles.

The core of Theano programming is to express mathematical relationships with symbol placeholders.

 

Components of the graph Structure

This code is implemented:

importtheano.tensor as Tx= T.matrix('x')y= T.matrix('y')z= x + y


Variable node (variable nodes)

Red. All variable nodes have owners, where the owner of x and y is none. The owner of z is apply.

 

Operation node (op nodes)

Green. Represents the operations between various variables (for example, +,-, **, sum (), tanh (), and so on ).

 

Apply nodes)

In blue. Other nodes are connected.

 

 

Analyze nodes attributes

The following code analyzes the node attributes.

Importtheano. tensor as Tx = T. dmatrix ('x') y = x * 2. >>> y. owner. op. name 'elemwise {mul, no_inplace} '# The owner of y is apply, and the op of apply is 'elemwise {mul, no_inplace}' >>> len (y. owner. inputs) 2 # two inputs >>> y. owner. inputs [0] x # The first input is x matrix> y. owner. inputs [1] InplaceDimShuffle {x, x }. 0
# Note that the second input here is not 2, but a matrix frame of the same size as x, because it will be multiplied only when broadcast is required.

>>> Type (y. owner. inputs [1]) <class 'theano. tensor. basic. tensorVariable '>>> type (y. owner. inputs [1]. owner) <class 'theano. gof. graph. apply '>>>> y. owner. inputs [1]. owner. op <class 'theano. tensor. elemwise. dimShuffle object at 0x14675f0 '> # broadcast 2 with DimShuffle >>> y. owner. inputs [1]. owner. inputs [2.0] # The owner of the matrix framework is 2.


Automatic Optimization

Compiling Theano is actually compiling a graph. This figure starts from the input variable to the output variable. Theano can detect key subgraphs and replace them to prevent duplicates for optimization. For example, replace xy/y with x.

For example

>>>import theano>>>a = theano.tensor.vector("a")     # declare symbolic variable>>>b = a + a ** 10                    #build symbolic expression>>>f = theano.function([a], b)        #compile function>>>print f([0, 1, 2])                 #prints `array([0,2,1026])`

Before Optimization





After Optimization

Welcome to the discussion and follow up on this blog, Weibo, and zhihu personal homepage for further updates ~

Reprinted, please respect the work of the author and keep the above text and link of the article completely. Thank you for your support!



The Reading Notes of the three compositions should be summarized, structured, commented, and prepared. The composition of the three good sentences and the copywriting should not be a book speed answer. The answer should be an article plus five points.

Thoughts on reading fate

A few days ago, I bought a book In Shucheng, called "dripping water, hiding the Sea". There are 300 classic philosophical stories in it. Now I will taste a little story called destiny.
Destiny refers to the fate of a single child. One is Divination by a monk as "champion" and the other is "beggar ". Two decades later, the original "champion" became a beggar, while the "beggar" became a "champion ".
God said: "I give everyone 1/3 of his fate, and the rest is how to grasp it ."
After reading this passage, I was very touched. There are many simple words to grasp and grasp fate, but how many people really grasp their own destiny? You don't have to blame your talent, let alone your own destiny, because fate is in your own hands and you can change it at any time! If you want
Reading "never mind weapons"
A person who has said goodbye to weapons is either a prisoner of the enemy or a prisoner of love. I am not very good at self-protection. I am really a person who gives up self-protection. just like the database of life, you can open all programs and read all files at any time without entering the password. what I am talking about is a prisoner in this sense. when I put myself in the sun, I realized that there was no disguise, and the days of concealment were disturbing. when I realized that the resistance was helpless, how much time was irretrievable, and how much memory gradually fades out from my heart. after all, a prisoner is a person who cannot resist harm, that is, to have enough courage to give up hope and must bear all the pressure to survive. originally, in a personal space, you can immerse yourself in your own fantasies, and you can create virtual flowers from the dust. a person who gives up self-protection cannot cheat himself, only by constantly purifying the inner world.

After reading the paper of hampir
Shakespeare's "Hamlet" is a classic masterpiece. on the surface, this book is not much different from historical legends. It tells the story of Prince Denmark's revenge for his father, which is full of bloody violence and death. as
Horazu, a Chinese character in the drama, said: you can hear rape and kill, unusual repairs, decisions in the dark, accidental slaughter, tactics of killing by hand, and self-harm ending. the twists and turns of the plot, closely around revenge
Expand. he hurried back to China from wandunburg, Germany to attend his father's funeral. What makes him unacceptable was that he did not catch up with his father's funeral, he witnessed the wedding of his mother and uncle kraudis, which had made hamwright suspect. In addition, at night, he met his father's dead soul on the terrace of the palace Castle and mourned, this violent behavior was done by Uncle James and asked him to avenge his father. so far, he began a difficult revenge process, and began a battle with kradis. in the end, the sword of revenge was issued to kradiss.

Count of Christchurch
Love is complete, hate is thorough. the reward is complete, and the revenge is complete. this is what I feel most after reading "Revenge of Christchurch. there is a saying in China that revenge of a gentleman is not too late for ten years. Revenge also needs to be refined and powerful, and it is not just a matter of time. the Count of Christchurch explained the saying most specifically with his own actions. after 14 years of his career in the dungeon, his life is to find his loved ones, beneents, and enemies. after confirming the person we are looking for, he did not go through the fire as we have seen in martial arts novels. he chose his own method. for the ship owner who once had favor with him, he did his best and silently supported him. In various ways, he never let them know that he was actually here for good. if his reward is touching, his revenge is so full that we are a little surprised when we have a few bits.
Interpretation of dreams
Freuch (1856 -- l939) is a famous Austrian psychologist and founder of the School of spiritual analysis. his work spans half a century and has a wide and profound influence on literature, philosophy, theology, ethics, aesthetics, political science, sociology, and mass psychology, if we use the scope of the impact as a measure of greatness, then freusi is undoubtedly the greatest psychologist. in the history of human thoughts, freuch initiated another revolution of the neighborhood. He pointed out that the human consciousness cannot be controlled by consciousness, and the human subconscious contains a huge psychological content, in his most rational voice, he told us about the irrational nature of mankind. interpreting dreams ...... remaining full text>

Who has the English 3 Study Notes website?

The open English examination of TVU consists of the formative examination and the final course examination. The Formative examination accounts for 50% of the total score, and the final course examination accounts for 50%.
The final score of formative assessment is 100 points, which accounts for 50% of the total score of the course. It consists of three parts: General Unit learning score, staged test score, and learning performance score. There are three points for each common unit, with a total of 45 points;
Each test has 15 points, totaling 45 points, and the learning performance is 10 points.
Can help you
 

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.