Do you like potato chips? I love you. I live in Germany now, but I'm dying for the paprika flavor and the cream onion flavor. Sometimes I also pick up Pringles.
One day, I wondered, "How is potato chips manufactured?", So with the strongest combination of ** potato ** and ** beer ** in one hand, THE MAKING (55) potato chips can be made. Up to. I was thinking that I could do this with vague potato chips, but suddenly
** This is the same idea as Tensorflow, isn't it? ?? ** **
I noticed.
When I started to touch Tensorflow myself, I was told that "I can't calculate unless I build a network and then send data withtf.Session ()
", but I wasn't used to the idea of a network. So it was difficult to understand.
So I was trying to understand it by replacing it with another one. As an example, the production of potato chips helped me to understand.
So, I recommend you to read the following articles after watching the above video ~~ with potato chips and beer ~~.
comment
――This is just a summary of how I understood it, so some people may say, "You should understand it from mathematics from a neural network!", But the first intuitive understanding Please note that we will provide such an example at the stage of. (I'll just make an excuse that it's a memo for myself ** (sweat) ――I think that thinking about networks and data separately is not just for Tensorflow, but for the common understanding of deep learning as a whole, but for the time being, let's consider Tensorflow as an example.
First of all, a major feature of Tensorflow is that calculations are not executed just by forming a network.
import tensorflow as tf
###network
a = tf.constant(1)
b = tf.constant(1)
add_op = tf.add(a, b) #Addition
###output
print(add_op)
Tensor("Add:0", shape=(), dtype=int32)
So how do you understand this? Those who are accustomed to machine learning to some extent know that "network and data are separate, and the accuracy changes depending on how the network is constructed, and the accuracy also changes depending on the amount (or quality) of data."
But usually, when you calculate, you think about operations on the data itself. For example, when calculating 1 + 1, add the data 1 and the data 1. That gives us a data of 2. This is 1 + 1 = 2. However, in machine learning and deep learning, we take the procedure of thinking about the operation of ● + △ and putting data in ● and △ to obtain the result. That is, it is implemented as follows:
import tensorflow as tf
###network
a = tf.placeholder(tf.float32) # ●
b = tf.placeholder(tf.float32) # △
a_add_b = tf.add(a, b) # ● + △
with tf.Session() as sess:
a_, b_, a_add_b_ = sess.run([a, b, a_add_b], feed_dict={a: 1, b: 1})
###output
print("%i + %i = %i" % (a_, b_, a_add_b_))
1 + 1 = 2
Let's see how to understand this from the potato manufacturing site.
Potato Chips Factory
-Potatoes in stock
=> In order to perform these series of operations, it is first necessary to prepare the necessary machines for each process. (Peeling machine, separating human, slicing machine, etc ...) After that, arrange them in the required order. (** Network construction **)
Of course, the machines required for each process could be used for other vegetables. The washing process could be used for vegetable chips in general, and the crushing process could be used for more (such as the process of making vegetable juice?). Therefore, it cannot be said that the machine in the process has a one-to-one correspondence with the object to be flown (potato in this case). To put it the other way around, the machine can be used when other things are flowing. (** Independence on network data **)
Tensorflow is doing the same. However, Tensorflow has all the necessary machines for each process (** API **), so we will decide how to combine them and what to put into the process (potato?). I have to decide. So, in Tensorflow, the amount that is flushed is called ** Tensor **. After that, you need to actually stream the object. (Otherwise, you can't eat potato chips (laughs). When you play it, turn on the power with
tf.Session ()
and start manufacturing (laughs)
** Caution ** "Independence" here does not mean "there is a network that gives the best results with any data because the network does not depend on data", but "the content of the data ( If the text, image etc ...) and the input / output shape match, the calculation can be performed using the same network. ”It refers to the possibility (Capability).
Thinking this way, does the data you put in tf.placeholder
gradually look like potatoes? Would you like to eat potato chips with sess.run ()
?
This is a poor example, but I would be very honored if it could be useful for intuitive understanding.
THE MAKING (55) until potato chips are made
Recommended Posts