# Something interesting

No matter what field you are in, you can do research in the growing period, dedicate into the industry in the steady period, and develop education in the saturation period. Obviously, Andrew Ng is a sensible person.

# 楽しい

To be honest, we have a decent job, house, car at the age of 25, should not complain more. However, cars/houses/good jobs, all of them, are general commodities, others may have them of ten times or even of hundred times than of what I have. But the ten years of youth, everyone has only one time.

So, please remember this thing, when you are 26 years old and decide whether you want to be a 30-year-old Doctor.

# Semiring

```import numpy as np
import networkx as nx
from functools import reduce
import matplotlib.pyplot as plt

connect_graph = np.array([[0, 1, 0, 0, 0],
[0, 0, 0, 1, 0],
[0, 0, 0, 1, 0],
[0, 0, 0, 0, 1],
[0, 0, 1, 0, 0]])

return a or b

def ring_multi(a, b):
return a and b

def dot_product(i, j):
row = connect_graph[i]
column = connect_graph[:,j]
return reduce(ring_add, [ring_multi(a, b) for a, b in zip(row, column)])

def next_generation(connect_graph):
candidate_number = connect_graph.shape

new_connect_graph = np.zeros((candidate_number, candidate_number))

for i in range(candidate_number):
for j in range(candidate_number):
new_connect_graph[i][j] = dot_product(i,j)

return new_connect_graph

new_connect_graph = next_generation(connect_graph)

def draw_graph(connect_graph):
G = nx.DiGraph()

candidate_number = connect_graph.shape

node_name = list(range(candidate_number))

for i in range(candidate_number):
for j in range(candidate_number):
if connect_graph[i][j]:

nx.draw(G, with_labels=True)

plt.show()

draw_graph(new_connect_graph)```

# Variational inference for Bayes Network

In general neural networks have a sort of loss like that:

However, The part of the denominator integral is intractable of finding an analytic solution solution in practice. Therefore, we are going to make a distribution approaching the original distribution. KL divergence can be used to indicate the difference between these two distributions.

We fall,
We break,
We fail,

But then,

We rise,
We heal,
We overcome.

# Printing a pyramid matrix

How to print a pyramid matrix like that:

`n = 2[1, 1, 1][1, 2, 1][1, 1, 1]n = 3[1, 1, 1, 1][1, 2, 2, 1][1, 2, 2, 1][1, 1, 1, 1]n = 4[1, 1, 1, 1, 1][1, 2, 2, 2, 1][1, 1, 3, 2, 1][1, 2, 2, 2, 1][1, 1, 1, 1, 1]`
```def func(N):
N += 1
matrix = [[1 for _ in range(N)] for _ in range(N)]
cnt = 0

while cnt < N:
# UP
for i in range(cnt, N - cnt - 1):
matrix[cnt][i] = cnt + 1

# RIGHT
for i in range(cnt, N - cnt - 1):
matrix[i][N - cnt - 1] = cnt + 1

# DOWN
for i in range(N - cnt - 1, cnt, -1):
matrix[N - cnt - 1][i] = cnt + 1

# LEFT
for i in range(N - cnt, cnt, -1):
matrix[N - cnt - 1][cnt] = cnt + 1

cnt += 1

return matrix

if __name__ == "__main__":
matrix = func(N=4)

for line in matrix:
print(line)
```