-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
July update
- Loading branch information
Showing
11 changed files
with
493 additions
and
2,313 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,7 +12,6 @@ | |
|
||
[ml-notes.akkefa.com](ml-notes.akkefa.com) | ||
|
||
|
||
#### Docs build | ||
|
||
```bash | ||
|
Large diffs are not rendered by default.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
{ | ||
"cells": [ | ||
{ | ||
"cell_type": "markdown", | ||
"metadata": {}, | ||
"source": [ | ||
"# Graph Equations\n", | ||
"\n", | ||
"Explaining the graph neural networks equations\n", | ||
"\n", | ||
"## GCN layer\n", | ||
"\n", | ||
"Semi-Supervised Classification with Graph Convolutional Networks\n", | ||
"https://arxiv.org/pdf/1609.02907.pdf\n", | ||
"\n", | ||
"$$\n", | ||
"h_i^{(l+1)}=\\sigma\\left(\\sum_{j \\in \\mathcal{N}_i} \\frac{1}{c_{i j}} h_j^{(l)} W^{(l)}\\right)\n", | ||
"$$\n", | ||
"\n", | ||
"where 𝐖(ℓ+) denotes a trainable weight matrix of shape [num_output_features, num_input_features] and 𝑐𝑤,𝑣 refers to a fixed normalization coefficient for each edge.\n", | ||
"\n", | ||
"PyG implements this layer via GCNConv" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 1, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [] | ||
} | ||
], | ||
"metadata": { | ||
"kernelspec": { | ||
"display_name": "notes", | ||
"language": "python", | ||
"name": "python3" | ||
}, | ||
"language_info": { | ||
"codemirror_mode": { | ||
"name": "ipython", | ||
"version": 3 | ||
}, | ||
"file_extension": ".py", | ||
"mimetype": "text/x-python", | ||
"name": "python", | ||
"nbconvert_exporter": "python", | ||
"pygments_lexer": "ipython3", | ||
"version": "3.11.4" | ||
}, | ||
"orig_nbformat": 4 | ||
}, | ||
"nbformat": 4, | ||
"nbformat_minor": 2 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,128 @@ | ||
{ | ||
"cells": [ | ||
{ | ||
"cell_type": "markdown", | ||
"metadata": {}, | ||
"source": [ | ||
"# ML Notation / Equations\n", | ||
"\n", | ||
"## Notation\n", | ||
"\n", | ||
"```{list-table}\n", | ||
":widths: 20 70 10\n", | ||
":header-rows: 1\n", | ||
":align: \"center\"\n", | ||
"\n", | ||
"* - Symbol\n", | ||
" - Formula\n", | ||
" - Explained\n", | ||
"* - $\\mu$\n", | ||
" - $\\sum_{x} k P(X=x) = \\int_{-\\infty}^{\\infty} x f(x) d x$\n", | ||
" - [🔗](expected-value)\n", | ||
"* - $V(X)$ or $\\sigma^2$ \n", | ||
" - $E[(X - E[X])^2] = E[(X - \\mu)^2] = E[X^2] - E[X]^2$\n", | ||
" - [🔗](variance-link)\n", | ||
"* - $\\sigma$\n", | ||
" - $\\sqrt{V(X)}$\n", | ||
" - Standard deviation\n", | ||
"* - $Cov(X,Y)$ \n", | ||
" - Covariance of X and Y\n", | ||
" - Covariance of X and Y\n", | ||
"* - $\\bar{X}$\n", | ||
" - The sample \n", | ||
" - The sample mean is an average value\n", | ||
"* - $\\delta$\n", | ||
" - $\\delta(v)$\n", | ||
" - Activation fucntions, sigmoid, relu, etc.\n", | ||
"\n", | ||
"```\n", | ||
"\n", | ||
"\n", | ||
"## Equations\n", | ||
"\n", | ||
"### Cosine Similarity\n", | ||
"Cosine similarity is a metric used to measure the similarity between two vectors in a multi-dimensional space.\n", | ||
"Cosine similarity measures the cosine of the angle between two non-zero vectors in an n-dimensional space.\n", | ||
"\n", | ||
"Formula = dot product / normalized sum of squares\n", | ||
"\n", | ||
"$$\n", | ||
"\\text{cos}(x,y) = \\frac{x \\cdot y}{\\sqrt{x^2} \\cdot \\sqrt{y^2}} = \\frac{\\sum_{i=1}^n A_i B_i}{\\sqrt{\\sum_{i=1}^n A_i^2} \\sqrt{\\sum_{i=1}^n B_i^2}}\n", | ||
"$$\n", | ||
"\n", | ||
"#### Properties\n", | ||
"\n", | ||
"- **Scale Invariance** Cosine similarity is scale-invariant, meaning it is not affected by the magnitude of the vectors, only by their orientations.\n", | ||
"- One hot and multi hot vectors easily.\n" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 2, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"import torch\n", | ||
"from torch.nn import functional as F" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 23, | ||
"metadata": {}, | ||
"outputs": [ | ||
{ | ||
"name": "stdout", | ||
"output_type": "stream", | ||
"text": [ | ||
"tensor(0.7071)\n", | ||
"tensor(0.7071)\n", | ||
"tensor(0.7071)\n", | ||
"tensor(0.7071)\n" | ||
] | ||
} | ||
], | ||
"source": [ | ||
"v1 = torch.tensor([0, 0, 1], dtype=torch.float32)\n", | ||
"v2 = torch.tensor([0, 1, 1],dtype=torch.float32)\n", | ||
"\n", | ||
"print(F.cosine_similarity(v1, v2 , dim=0))\n", | ||
"\n", | ||
"print(F.normalize(v1, dim=0) @ F.normalize(v2, dim=0))\n", | ||
"\n", | ||
"print(torch.norm(v1) / torch.norm(v2))\n", | ||
"\n", | ||
"print( torch.matmul(v1, v2.T) / ( torch.sqrt( torch.sum(v1 ** 2)) * torch.sqrt( torch.sum(v2 ** 2))) )\n" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [] | ||
} | ||
], | ||
"metadata": { | ||
"kernelspec": { | ||
"display_name": "notes", | ||
"language": "python", | ||
"name": "python3" | ||
}, | ||
"language_info": { | ||
"codemirror_mode": { | ||
"name": "ipython", | ||
"version": 3 | ||
}, | ||
"file_extension": ".py", | ||
"mimetype": "text/x-python", | ||
"name": "python", | ||
"nbconvert_exporter": "python", | ||
"pygments_lexer": "ipython3", | ||
"version": "3.11.4" | ||
}, | ||
"orig_nbformat": 4 | ||
}, | ||
"nbformat": 4, | ||
"nbformat_minor": 2 | ||
} |