[PYTHON] I tried to solve the E qualification problem collection [Chapter 1, 5th question]

This is the first post.

I am studying for E qualifications sponsored by JDLA (Japan Deep Learning Association). As a countermeasure, we use "Thorough Strategy Deep Learning E Qualification Engineer Problem Collection". However, when solving the problem, typographical errors are sometimes found. Since this is the only E-qualification countermeasure book, I would like to write one question per article for those who are studying from now on. Please point out any mistakes.

Chapter 1 5th question

First, let's look at the question sentences and answers in the text. Next, I will post the result I solved and the answer of the poster.

Text question sentence

Select one option that applies to (a) to (d) of the following formula. However, the same option may apply in more than one place.

queue

A=
\begin{pmatrix}
1 & 0 & 0\\
0 & 1 & 2
\end{pmatrix}

Is decomposed into singular values ​​and expressed in the form of $ A = U \ Sigma V ^ T $, as follows.

\Sigma =
\begin{pmatrix}
(A) & 0 & 0\\
0 & (I) & 0
\end{pmatrix}
\\
U=
\begin{pmatrix}
0 & 1\\
(C) & 0
\end{pmatrix}
\\
V=
\begin{pmatrix}
0 & 1 & 0\\
\frac{1}{\sqrt{5}} & 0 & -\frac{2}{\sqrt{5}}\\
\frac{2}{\sqrt{5}} & 0 & (D)
\end{pmatrix}

A. -1 B. 0 C. 1 D. 2 E. -\sqrt{5} F. \sqrt{5} G. -\frac{1}{\sqrt{5}} H. \frac{1}{\sqrt{5}}

Text answer

** (A) C, (B) F, (C) C, (D) H **

First, $ A \ for the singular value of the m × n rectangular matrix $ A $, that is, the $ (i, i) $ component (i = 1, ..., min {m, n}) of $ \ Sigma $. The positive square roots of the ^ TA $ eigenvalues ​​are arranged in descending order (largest order).

A^T A=
\begin{pmatrix}
1 & 0\\
0 & 5
\end{pmatrix}

So its eigenvalue is

det(\lambda I - A ^T A) = det
\begin{pmatrix}
\lambda -1 & 0\\
0 & \lambda -5
\end{pmatrix}
= 0

Solving, $ \ lambda = 1, 5 $. The singular value of $ A $ is $ \ sigma = 1, \ sqrt {5} $, so if you arrange them in descending order, (A) is 1 and (B) is $ \ sqrt {5} $ (** A = C, i = F **). Here, the first column of $ U $ is the eigenvector $ u = (() u_x, u_y) ^ T $ corresponding to the eigenvalue 5 of $ A ^ T A $, which has a magnitude of 1. Therefore,

\begin{pmatrix}
1 & 0\\
0 & 5
\end{pmatrix}
\begin{pmatrix}
u_x\\
u_y
\end{pmatrix}
=5
\begin{pmatrix}
u_x\\
u_y
\end{pmatrix}

To get the solution that $ u_x = 0 $ and $ u_y $ are arbitrary real numbers. Here we can see that $ u_y = \ pm1 $ must be in order for $ u $ to be 1 in size. Also, each column of $ V $ is an eigenvector of $ A ^ T A $, but these must satisfy ** orthonormality **. So put $ v_1 = (0, 1/\ sqrt {5}, 2/\ sqrt {5}) ^ T $, $ v_3 = (0, -2/\ sqrt {5}, v_z) ^ T $ For example, $ v_1 ^ T \ cdot v_3 = 0 $ due to their orthogonality. Therefore,

0 \cdot 0 + \frac{1}{\sqrt{5}} \cdot \left( -\frac{2}{\sqrt{5}} \right) + \frac{2}{\sqrt{5}} v_z = 0

Then, (d) $ v_z = 1/\ sqrt {5} $ is obtained (** d = H ). Finally, you can confirm by substitution whether the value that applies to (c) is 1 or -1, and identify it as 1. ( C = C **).

I tried to solve it myself

When I tried to solve this problem myself, the text answer and the choices were different. There is a good chance that your calculation is wrong, so substitute the options in the text answer for $ \ Sigma $, $ U $, and $ V $ to calculate $ U \ Sigma V ^ T $. When I tried it, it became as follows.

\begin{eqnarray}
U \Sigma V^T
&=&
\begin{pmatrix}
0 & 1\\
1 & 0
\end{pmatrix}
\begin{pmatrix}
1 & 0 & 0\\
0 & \sqrt{5} & 0
\end{pmatrix}
\begin{pmatrix}
0 & \frac{1}{\sqrt{5}} & \frac{2}{\sqrt{5}}\\
1 & 0 & 0\\
0 & -\frac{2}{\sqrt{5}} & \frac{1}{\sqrt{5}}
\end{pmatrix}\\
&=&
\begin{pmatrix}
0 & \sqrt{5} & 0\\
1 & 0 & 0
\end{pmatrix}
\begin{pmatrix}
0 & \frac{1}{\sqrt{5}} & \frac{2}{\sqrt{5}}\\
1 & 0 & 0\\
0 & -\frac{2}{\sqrt{5}} & \frac{1}{\sqrt{5}}
\end{pmatrix}\\
&=&
\begin{pmatrix}
\sqrt{5} & 0 & 0\\
0 & -\frac{1}{\sqrt{5}} & \frac{2}{\sqrt{5}}
\end{pmatrix}
\end{eqnarray}

It has a different composition than $ A $. I am looking for a singular value of $ A $ in the answer, but it is probably because "(A) is 1 and (B) is $ \ sqrt {5} $".

Let's calculate $ U \ Sigma V ^ T $ again in the presence of unknowns. Let (a) be w, (b) be x, (c) be y, and (d) be z. Then

\begin{eqnarray}
U \Sigma V^T
&=&
\begin{pmatrix}
0 & 1\\
y & 0
\end{pmatrix}
\begin{pmatrix}
w & 0 & 0\\
0 & x & 0
\end{pmatrix}
\begin{pmatrix}
0 & \frac{1}{\sqrt{5}} & \frac{2}{\sqrt{5}}\\
1 & 0 & 0\\
0 & -\frac{2}{\sqrt{5}} & z
\end{pmatrix}\\
&=&
\begin{pmatrix}
0 & x & 0\\
wy & 0 & 0
\end{pmatrix}
\begin{pmatrix}
0 & \frac{1}{\sqrt{5}} & \frac{2}{\sqrt{5}}\\
1 & 0 & 0\\
0 & -\frac{2}{\sqrt{5}} & z
\end{pmatrix}\\
&=&
\begin{pmatrix}
x & 0 & 0\\
0 & \frac{wy}{\sqrt{5}} & \frac{2wy}{\sqrt{5}}
\end{pmatrix}
\end{eqnarray}

If you compare this with the $ (1,1) $ component of $ A $, you can see that $ x = 1 $. Since the singular values ​​of $ A $ were 1 and $ \ sqrt {5} $, we know that $ w = \ sqrt {5} $. By comparing the $ (2,2) $ components, we can see that $ y = 1 $. Due to the nature of singular value decomposition, $ V $ is an orthonormal matrix, so if we take the inner product of the vector $ v_1 $ in the first column and the vector $ v_3 $ in the third column,

v_1 \cdot v_3
=
\begin{pmatrix}
0\\
\frac{1}{\sqrt{5}}\\
\frac{2}{\sqrt{5}}
\end{pmatrix}
\cdot
\begin{pmatrix}
0\\
-\frac{2}{\sqrt{5}}\\
z
\end{pmatrix}
=
0 \cdot 0 - \frac{1}{\sqrt{5}}\ \cdot \frac{2}{\sqrt{5}} + \frac{2}{\sqrt{5}} z
=
-\frac{2}{5} + \frac{2}{\sqrt{5}} z
=
0

Solving this, we find $ z = 1/\ sqrt {5} $. From the above, the answer of the poster is as follows.

Poster's answer

** (A) F, (B) C, (C) C, (D) H **

As an aside, maybe $ u = (() u_x, u_y) ^ T $ is just a typo, and I think it's $ u = (u_x, u_y) ^ T $.

Recommended Posts

I tried to solve the E qualification problem collection [Chapter 1, 5th question]
I tried to solve the problem with Python Vol.1
The 15th offline real-time I tried to solve the problem of how to write with python
I tried to solve the shift scheduling problem by various methods
I tried to solve the 2020 version of 100 language processing [Chapter 3: Regular expressions 25-29]
I tried to solve the inverted pendulum problem (Cart Pole) by Q-learning.
I tried to implement the traveling salesman problem
I tried to solve the 2020 version of 100 language processing knocks [Chapter 3: Regular expressions 20 to 24]
I tried to solve the 2020 version of 100 language processing knocks [Chapter 1: Preparatory movement 00-04]
I tried to pass the G test and E qualification by training from 50
I tried to solve the 2020 version of 100 language processing knocks [Chapter 1: Preparatory movement 05-09]
I tried to solve the soma cube with python
I tried to solve the virtual machine placement optimization problem (simple version) with blueqat
I tried to solve a combination optimization problem with Qiskit
How to write offline real time I tried to solve the problem of F02 with Python
I tried to move the ball
I tried to estimate the interval.
I tried to solve the ant book beginner's edition with python
I tried to solve 100 language processing knock 2020 version [Chapter 2: UNIX commands 10 to 14]
I wanted to solve the ABC164 A ~ D problem with Python
I tried to solve 100 language processing knock 2020 version [Chapter 2: UNIX commands 15 to 19]
I tried to solve the first question of the University of Tokyo 2019 math entrance exam with python sympy
I tried "Implementing a genetic algorithm (GA) in python to solve the traveling salesman problem (TSP)"
I tried to summarize the umask command
I tried to recognize the wake word
I tried to summarize the graphical modeling.
I tried to let optuna solve Sudoku
I tried to estimate the pi stochastically
I tried to touch the COTOHA API
Python: I tried the traveling salesman problem
I tried to solve TSP with QAOA
I tried to estimate the similarity of the question intent using gensim's Doc2Vec
I tried to express sadness and joy with the stable marriage problem.
How to write offline real time I tried to solve E11 with python
The 19th offline real-time how to write reference problem to solve with Python
How to write offline real time I tried to solve E12 with python
Try to solve the fizzbuzz problem with Keras
I tried web scraping to analyze the lyrics.
Try to solve the Python class inheritance problem
I tried to optimize while drying the laundry
I tried to save the data with discord
I tried to touch the API of ebay
I tried to correct the keystone of the image
Python / PEP8> E128 I tried to solve continuation line under-indented for visual indent
I want to solve APG4b with Python (Chapter 2)
Qiita Job I tried to analyze the job offer
LeetCode I tried to summarize the simple ones
I tried to predict the price of ETF
I tried to vectorize the lyrics of Hinatazaka46!
[Keras] I tried to solve a donut-type region classification problem by machine learning [Study]
Python practice 100 knocks I tried to visualize the decision tree of Chapter 5 using graphviz
[Pyhton] I want to solve the problem that tkinter does not work on MacOS11
I tried to learn the sin function with chainer
I tried to graph the packages installed in Python
I tried to detect the iris from the camera image
I tried to summarize the basic form of GPLVM
Try to solve the problems / problems of "Matrix Programmer" (Chapter 1)
Try to solve the internship assignment problem with Python
I tried to touch the CSV file with Python
I tried to predict the J-League match (data analysis)
I tried to put pytest into the actual battle