Placeholder Image

字幕列表 影片播放

  • Hello, and welcome.

  • In this video, we'll provide an overview of tensors, variables, and placeholders.

  • A tensor is a special type of mathematical object that was originally used to analyze

  • the way that materials stretch under tension.

  • Nowadays, a tensor typically refers to a multi-dimensional array.

  • To fully understand multi-dimensional arrays, we'll need to understand the concept of dimension,

  • which if you're familiar, is an important topic in physics.

  • The zero dimension is simply a point, or a single object.

  • The first dimension is a line, which can contain an infinite number of point elements.

  • A one-dimensional array only requires one coordinate to locate an element.

  • The second dimension can be seen as a flat surface, which can contain and infinite number

  • of lines.

  • To locate an element in a two-dimensional array, you need to specify two coordinates.

  • The third dimension can be seen as a volume, which can contain an infinite number of surfaces.

  • And the fourth dimension goes beyond what we can easily visualize, but you can think

  • of it as space time, or a volume that changes through time, something like that.

  • The main idea is that the dimension specifies the number of coordinates you'd need to locate

  • a specific point.

  • You can look here to see the mathematical objects.

  • And this table should help to reinforce the concept.

  • So let's define these arrays using TensorFlow:

  • If you want to experiment with these data structures, you should apply a few functions

  • and observe the behavior based on the different structure types.

  • The tensor structure gives us the freedom to shape the dataset the way we want it.

  • It's particularly helpful when dealing with images, since images have to encode a lot

  • of information.

  • Images have a width and a height, so it should be easy to see that we'd need at least a two-dimensional

  • structure.

  • But remember, the pixels of an image are broken down into three color channels: typically,

  • Red, Green, and Blue, or RGB.

  • So an image essentially needs three different matrices, to store the intensity of each color

  • channel.

  • That might look something like this:

  • As you can see, an image requires a third dimension for color, in order to represent

  • all the information.

  • So we can combine these three matrices together to form a tensor.

  • Now that we're more familiar with the structure of the data, we can take a look at how TensorFlow

  • handles variables.

  • To define variables, we simply use the command 'tf.variable'.

  • Variables need to be initialized before a graph can be run in a session, which can be

  • done using 'tf.initialize_all_variables'.

  • To update the value of a variable, we define an update function using 'tf.assign'.

  • We can then run the operation.

  • Let's first create a simple counter:

  • When the graph is launched, we'll need to add an initialization operation for the variables.

  • We can then start the session and run the graph.

  • After the variables are initialized, we print the initial value of the state variable, we

  • run the update operation, and then we print the result after each update.

  • If you want to feed data to TensorFlow from outside a model, you will need to use placeholders.

  • You can think of a placeholder like a variable that won't actually receive its data until

  • a later point.

  • To create one, you can use the 'placeholder' method.

  • You'll need to specify the data type, as well as the data type's precision in terms of the

  • number of bits.

  • Here, you can see each data type with the respective python syntax:

  • So now let's create a placeholder.

  • And then we'll define a simple multiplication operation.

  • Now we need to define and run the session.

  • But remember, the placeholder still doesn't hold a value, so if we run as is, we'd get

  • an error.

  • We can solve this by passing an extra argument when we call the session.

  • We'll use the argument 'feed_dict', a dictionary that contains each placeholder name followed

  • by its respective data:

  • We can pass any kind of tensor through the placeholders to get the answer to the multiplication

  • operation:

  • By now you should understand the purpose of tensors, variables, and placeholders.

  • Thank you for watching this video.

Hello, and welcome.

字幕與單字

單字即點即查 點擊單字可以查詢單字解釋

B1 中級

用Tensorflow進行深度學習--張力器、變量和佔位符。 (Deep Learning with Tensorflow - Tensors, Variables and Placeholders)

  • 97 16
    scu.louis 發佈於 2021 年 01 月 14 日
影片單字