Understanding the Tensor (3): Real World Data

1.First of all

Organize the information you need to understand Tensor as your own notes. Today, I will give an example of data used in the real world of deep running. I will introduce how the data is expressed as a tensor.

And please read carefully how each data is expressed as ** Shape ** of tensor.

The previous post is here.

  1. Understanding Tensor (1): Dimension
  2. Understanding Tensor (2): Shape

2. What is a tensor?

  1. Tensor is a just a container for data.
  2. The data are almost numerical data
  3. Therefore, Tensor is a container for number.

A tensor is a container that holds numbers. It's simple.

3. Tensor example (Real World Data)

The table below shows commonly used data in the real world of deep running and its tensor information.

Data example name Tensor Shape
Vector Data* Matrix 2D Tensor (sample, feature)
Time Series Data 3D Tensor 3D Tensor (sample, timestep, feature)
Images 4D Tensor 4D Tensor (sample, height, width, channel)
Video 5D Tensor 5D Tensor (sample, frame, height, width, channel)

3.1. Vector Data(2D Tensor)

Here is an example of data for a list of people. Think of it as some kind of electoral roll. Suppose you have selected Age, ZIP Code, and Income as the Features that describe each public figure in the list, and collected data for 10,000 people (Samples). Since the data is in a matrix, it becomes a 2D tensor. The Shape of this 2D tensor is ** (Sample, Feature) = (10000,3) **. image.png

3.2.Time Series Data(3D Tensor) Consider time series data of the stock price of a company for one year.

Consider the structure of this data. For stock prices, we collect data on 250 business days all year round. Stock prices are aggregated in minutes. The stock market collects 390 minutes of data. Select the current price, the Highest Price, and the Lowest Price as the feature amount of stock purchase.

Therefore, the Shape of this time series is ** (Sample, Timestep, Feature) = (250, 390, 3) **.

image.png

3.3. Images(4D Tensor)

Image data. First, suppose you have 128 image data. Next, let's say the resolution is 256X256 pixels. It is a color image and consists of three channels (R, G, B).

Therefore, the Shape of this image data is ** (Sample, height, width, channel) = (128, 256, 256, 3) **. image.png

3.4. Video(5D Tensor) This is video data. For example, suppose you have four 60-second color video data with a resolution of 144X156. Assuming that the frame rate of this video is 4fps, it will consist of about 240 frames (240 frame = 60 sec * 4 frame / sec).

Therefore, the Shape of this video data is ** (Sample, Frames, Height, Width, Channel) = (4, 240, 144, 156, 3) **.

image.png

4. Summary

Data example Details Figure Tensor Shape
Vector Data* Personal Data image.png 2DTensor (sample,feature)=(10000,3)
Time Series Data Annual Stock Data image.png 3DTensor (sample,timestep,feature)=(250,260,3)
Images Batch of Color Images image.png 4DTensor (sample,height,width,channel)=(128,256,256,3)
Video Batch of Video Frames image.png 5DTensor (sample,frame,height,width,channel)=(4,240,144,156,3)

5. Reference materials

  1. Understanding Tensor (1): Dimension
  2. Understanding Tensor (2): Shape

Recommended Posts

Understanding the Tensor (3): Real World Data
Understanding the Tensor (2): Shape
Understanding Tensor (1): Dimension
Understand the tensor product (numpy.tensordot)
Gzip the data by streaming
About understanding the 3-point reader [...]
[Unexpectedly known? ] Introducing a real day in the data analysis department