Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
chengjun committed Jul 27, 2024
1 parent 230a57f commit 9dcc87f
Show file tree
Hide file tree
Showing 13 changed files with 468 additions and 330 deletions.
Binary file modified .DS_Store
Binary file not shown.

Large diffs are not rendered by default.

343 changes: 179 additions & 164 deletions notebook/.ipynb_checkpoints/05-02-networkx-checkpoint.ipynb

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
"source": [
"<div><img src=img/net22.png width='1000px'></div>\n",
"\n",
"# The random network model 随机网络模型\n"
"## The random network model 随机网络模型\n"
]
},
{
Expand All @@ -39,7 +39,7 @@
}
},
"source": [
"# Erdös-Rényi model (1960)\n",
"## Erdös-Rényi model (1960)\n",
"\n",
"Definition: A random graph is a graph of N nodes where each pair of nodes is connected by probability p.\n",
"\n",
Expand All @@ -58,7 +58,7 @@
}
},
"source": [
"## To construct a random network:\n",
"### To construct a random network:\n",
"- 1) Start with $N$ isolated nodes.\n",
"- 2) Select a node pair and generate a random number between 0 and 1.\n",
"If the number exceeds $p$, connect the selected node pair with a link,\n",
Expand Down Expand Up @@ -88,7 +88,7 @@
}
},
"source": [
"## BINOMIAL DISTRIBUTION: MEAN AND VARIANCE\n",
"### BINOMIAL DISTRIBUTION: MEAN AND VARIANCE\n",
"\n",
"**二项分布**即重复n次独立的**伯努利试验**。\n",
"\n",
Expand Down Expand Up @@ -130,7 +130,7 @@
}
},
"source": [
"# In summary:\n",
"## In summary:\n",
"- the number of links in a random network varies between realizations. \n",
"- Its expected value is determined by **N** and **p**. \n",
"- If we increase p a random network becomes denser: \n",
Expand All @@ -146,7 +146,7 @@
}
},
"source": [
"# Degree Distribution\n",
"## Degree Distribution\n",
"In a given realization of a random network some nodes gain numerous links, while others acquire only a few or no links. These differences are captured by the degree distribution, $p_k$. \n",
"\n",
"$p_k$ is the probability that a randomly chosen node has degree $k$. "
Expand Down Expand Up @@ -185,7 +185,7 @@
}
},
"source": [
"# POISSON DISTRIBUTION\n",
"## POISSON DISTRIBUTION\n",
"\n",
"- Most real networks are **sparse**, meaning that for them $<k>$ ≪ N. \n",
"- the degree distribution is well approximated by the Poisson distribution\n",
Expand Down Expand Up @@ -229,7 +229,7 @@
}
},
"source": [
"# The small world phenomenon 小世界现象\n",
"## The small world phenomenon 小世界现象\n",
"also known as **six degrees of separation**,\n",
"has long fascinated the general public. It states that if you choose any two\n",
"individuals anywhere on Earth, you will find a path of at most six acquaintances\n",
Expand All @@ -247,7 +247,7 @@
}
},
"source": [
"# Consider a random network with average degree $<k>$. \n",
"## Consider a random network with average degree $<k>$. \n",
"\n",
"A node i in this network has on average:\n",
"\n",
Expand All @@ -266,7 +266,7 @@
}
},
"source": [
"# 从For循环的角度理解\n",
"## 从For循环的角度理解\n",
"- 从这个节点i走一步,到达他/她的$<k>$个朋友\n",
"- 从节点i走两步,先到他/她的$<k>$个朋友,再到每个朋友的$<k>$个朋友。\n",
"- 。。。\n",
Expand All @@ -286,7 +286,7 @@
}
},
"source": [
"# 随机网络的直径\n",
"## 随机网络的直径\n",
"\n",
"> the expected number of nodes up to distance d from our starting node is $N(d)$ \n",
"\n",
Expand Down Expand Up @@ -335,7 +335,7 @@
}
},
"source": [
"# SIX DEGREES: EXPERIMENTAL CONFIRMATION\n",
"## SIX DEGREES: EXPERIMENTAL CONFIRMATION\n",
"The first empirical study of the small world phenomena took place in 1967\n",
"- Stanley Milgram, building on the work of Pool and Kochen, designed an experiment to measure the distances in social networks. \n",
"- Milgram chose a stock broker in Boston and a divinity student in Sharon, Massachusetts as targets. \n",
Expand All @@ -355,7 +355,7 @@
"source": [
"Using Facebook’s social graph of May 2011, consisting of 721 million active users and 68 billion symmetric friendship links, researchers found:\n",
"\n",
"# an average distance 4.74 between the users. \n",
"## an average distance 4.74 between the users. \n",
"\n",
"- Therefore, the study detected only ‘four degrees of separation’, closer to the prediction of than to Milgram’s six degrees.\n",
"\n",
Expand All @@ -381,7 +381,7 @@
}
},
"source": [
"# 大的聚集系数与小的网络直径如何并存?\n"
"## 大的聚集系数与小的网络直径如何并存?\n"
]
},
{
Expand Down Expand Up @@ -421,7 +421,7 @@
}
},
"source": [
"# 邻居彼此认识吗?\n",
"## 邻居彼此认识吗?\n",
"Local clustering coefficient\n",
"\n",
"We need to estimate the expected number of links $L_i$ between the node’s $k_i$ neighbors. \n",
Expand All @@ -441,7 +441,7 @@
}
},
"source": [
"# 局部聚集系数\n",
"## 局部聚集系数\n",
"\n",
"$<C_i> = \\frac{<L>}{\\frac{1}{2} k_i(k_i - 1)} = p = \\frac{<k>}{N}$\n",
"\n",
Expand All @@ -468,7 +468,7 @@
}
},
"source": [
"# WS模型 (1998)\n",
"## WS模型 (1998)\n",
"\n",
"Duncan Watts and Steven Strogatz proposed an extension of the random network model motivated by two observations:\n",
"- (a) Small World Property: In real networks the average distance between two nodes depends logarithmically on N\n",
Expand Down Expand Up @@ -534,7 +534,7 @@
}
},
"source": [
"# In summary\n",
"## In summary\n",
"- we find that the random network model does not capture the clustering of real networks. \n",
"- Instead real networks have a **much higher clustering coefficient** than expected for a random network of similar N and L. \n",
"- An extension of the random network model proposed by Watts and Strogatz [1998] addresses the coexistence of high <C> and the small world property. \n",
Expand Down Expand Up @@ -562,7 +562,7 @@
}
},
"source": [
"# BA模型 (1999)\n",
"## BA模型 (1999)\n",
"\n",
"Barabasi (1999) Emergence of scaling in random networks.Science-509-12\n",
"\n",
Expand All @@ -582,7 +582,7 @@
}
},
"source": [
"# 无标度的意义"
"## 无标度的意义"
]
},
{
Expand Down Expand Up @@ -666,7 +666,7 @@
}
},
"source": [
"# 无标度的意义\n",
"## 无标度的意义\n",
"> ### 在网络中随机抽取一个节点的度可以显著的不同于平均度$<k>$\n",
"\n",
"上图最为直接的描绘出了这种特点,即与正态分布等相比,`无标度网络下降的慢`。\n",
Expand Down Expand Up @@ -716,7 +716,7 @@
}
},
"source": [
"# 连续平均场\"Continuum Mean-Field\" \n",
"## 连续平均场\"Continuum Mean-Field\" \n",
"\n",
"\"Mean-Field\": many -> one\n",
"\n",
Expand All @@ -737,7 +737,7 @@
}
},
"source": [
"## 模型设定\n",
"### 模型设定\n",
"* 初始状态有$m_0$个节点\n",
"* 1. 增长原则:每次加入一个节点i (加入时间记为$t_i$), 每个节点的加入带来m条边,2m个度的增加\n",
"** 其中老节点分到的度数是m,新加入的那一个节点分到的度数为m.\n",
Expand Down Expand Up @@ -766,7 +766,7 @@
}
},
"source": [
"## 度的增长/时间依赖性\n",
"### 度的增长/时间依赖性\n",
"$k_i$在一个时间步获得一个度的概率表示为$\\prod (k_i) $, 那么有:\n",
"\n",
"$$\\prod (k_i) = \\frac{k_i}{\\sum k_i} = \\frac{k_i}{2mt}$$\n",
Expand All @@ -790,7 +790,7 @@
}
},
"source": [
"## 积分结果\n",
"### 积分结果\n",
"\n",
"$k_i = C (2t) ^ {-0.5} $ (1)\n",
"\n",
Expand All @@ -815,7 +815,7 @@
}
},
"source": [
"## 累积概率分布\n",
"### 累积概率分布\n",
"\n",
"当我们思考一个累积概率分布的时候,我们想要的是$k_i(t) < k$的概率:$P(k_i(t) < k) $\n",
"\n",
Expand Down Expand Up @@ -862,7 +862,7 @@
}
},
"source": [
"# 参考文献\n",
"## 参考文献\n",
"- Barabasi 2016 Network Science. Cambridge\n",
"- Barabasi (1999) Emergence of scaling in random networks.Science-509-12.pdf\n",
"- Barabasi (1999) Mean-field theory for scale-free random networks. PA.pdf\n",
Expand Down Expand Up @@ -900,7 +900,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.7.6"
"version": "3.8.8"
},
"latex_envs": {
"LaTeX_envs_menu_present": true,
Expand Down
41 changes: 41 additions & 0 deletions notebook/.ipynb_checkpoints/08-05-transformer-checkpoint.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -344,6 +344,47 @@
"![image-2.png](./img/attention8.png)\n"
]
},
{
"attachments": {},
"cell_type": "markdown",
"metadata": {
"ExecuteTime": {
"end_time": "2024-07-24T12:15:19.223210Z",
"start_time": "2024-07-24T12:15:19.219011Z"
},
"slideshow": {
"slide_type": "slide"
}
},
"source": [
"## Hands-on Machine Learning \n",
"\n",
"\n",
"![image-2.png](./img/attention9.png)\n",
"\n",
"All the code examples in this book https://github.com/ageron/handson-ml3\n"
]
},
{
"attachments": {},
"cell_type": "markdown",
"metadata": {
"ExecuteTime": {
"end_time": "2024-07-24T12:15:19.223210Z",
"start_time": "2024-07-24T12:15:19.219011Z"
},
"slideshow": {
"slide_type": "slide"
}
},
"source": [
"## Dive into Deep Learning \n",
"\n",
"![image-2.png](./img/attention10.png)\n",
"\n",
"All the code examples in this book http://d2l.ai/\n"
]
},
{
"cell_type": "markdown",
"metadata": {
Expand Down
10 changes: 5 additions & 5 deletions notebook/01-intro2css.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -57,11 +57,11 @@
},
{
"cell_type": "code",
"execution_count": 2,
"execution_count": 1,
"metadata": {
"ExecuteTime": {
"end_time": "2021-07-23T08:39:12.575615Z",
"start_time": "2021-07-23T08:39:12.570247Z"
"end_time": "2024-07-27T00:58:59.873777Z",
"start_time": "2024-07-27T00:58:59.817394Z"
},
"cell_style": "center",
"code_folding": [
Expand Down Expand Up @@ -942,7 +942,7 @@
"metadata": {
"celltoolbar": "幻灯片",
"kernelspec": {
"display_name": "Python 3 (ipykernel)",
"display_name": "Python 3",
"language": "python",
"name": "python3"
},
Expand All @@ -956,7 +956,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.9.7"
"version": "3.8.8"
},
"latex_envs": {
"LaTeX_envs_menu_present": true,
Expand Down
Loading

0 comments on commit 9dcc87f

Please sign in to comment.