From 1e38d0654179d21893073f70bf8bbe0b0d5dd829 Mon Sep 17 00:00:00 2001 From: Ikram Ali Date: Sat, 7 Oct 2023 10:44:23 +0500 Subject: [PATCH 1/6] c --- docs/requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/requirements.txt b/docs/requirements.txt index 05ad6ce..6365206 100644 --- a/docs/requirements.txt +++ b/docs/requirements.txt @@ -1,4 +1,4 @@ -torch~=2.0 +torch~=2.1 seaborn~=0.12 scipy~=1.10 scikit-learn~=1.2 From cfd8589b79ed6ede339957f6eda1008c7a971f8b Mon Sep 17 00:00:00 2001 From: Ikram Ali Date: Sat, 7 Oct 2023 10:47:40 +0500 Subject: [PATCH 2/6] c --- docs/deep_learning/evaluation_metrics.md | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/docs/deep_learning/evaluation_metrics.md b/docs/deep_learning/evaluation_metrics.md index 5748b50..074aa20 100644 --- a/docs/deep_learning/evaluation_metrics.md +++ b/docs/deep_learning/evaluation_metrics.md @@ -115,6 +115,14 @@ $$ \text{recall} = \frac{\text{TP}}{\text{TP} + \text{FN}} $$ +```{note} +Precision is about your prediction. +Recall is about reality. + +If your job is to identify thieves. +``` + + #### False Negative Rate False Negative Rate (FNR) tells us what proportion of the positive class got incorrectly classified by the classifier. From a69d682c2892cfa6e0424b4dcbda2c91ca2a49b8 Mon Sep 17 00:00:00 2001 From: Ikram Ali Date: Wed, 11 Oct 2023 13:34:22 +0500 Subject: [PATCH 3/6] version updated --- docs/requirements.txt | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/docs/requirements.txt b/docs/requirements.txt index 6365206..af5fe9c 100644 --- a/docs/requirements.txt +++ b/docs/requirements.txt @@ -1,10 +1,10 @@ torch~=2.1 -seaborn~=0.12 -scipy~=1.10 -scikit-learn~=1.2 -torchmetrics~=0.11 +seaborn~=0.13 +scipy~=1.11 +scikit-learn~=1.3 +torchmetrics~=1.2 myst-nb~=0.17 -sphinx-design~=0.3 +sphinx-design~=0.5 sphinx-copybutton xlrd~=2.0 scikit-surprise~=1.1 From 043c8537713ed810f26567ab6292c5c1a640d6a2 Mon Sep 17 00:00:00 2001 From: Ikram Ali Date: Wed, 11 Oct 2023 13:45:18 +0500 Subject: [PATCH 4/6] c --- docs/torch/pytorch_fundamental.ipynb | 93 ++++++++++++++++++++++++++-- 1 file changed, 89 insertions(+), 4 deletions(-) diff --git a/docs/torch/pytorch_fundamental.ipynb b/docs/torch/pytorch_fundamental.ipynb index e152f38..8b127fe 100644 --- a/docs/torch/pytorch_fundamental.ipynb +++ b/docs/torch/pytorch_fundamental.ipynb @@ -12,22 +12,23 @@ }, { "cell_type": "code", - "execution_count": 1, + "execution_count": 2, "metadata": {}, "outputs": [ { "data": { "text/plain": [ - "'2.0.0'" + "'2.1.0'" ] }, - "execution_count": 1, + "execution_count": 2, "metadata": {}, "output_type": "execute_result" } ], "source": [ "import torch\n", + "import numpy as np\n", "\n", "torch.__version__" ] @@ -1734,6 +1735,90 @@ "x[0, 0, :] # same as x[0][0]" ] }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Pytorch Best Practise" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "You can also use torch.as_tensor() to convert a numpy array to a torch tensor, This will not create a new copy of the data" + ] + }, + { + "cell_type": "code", + "execution_count": 5, + "metadata": {}, + "outputs": [], + "source": [ + "a = np.random.rand(3, 3)\n", + "# Bad way\n", + "t1 = torch. tensor(a)\n", + "\n", + "# Good way\n", + "t2 = torch.as_tensor(a)\n", + "t3 = torch.from_numpy(a)\n" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "Avoid cpu, item() these will use functions to tranfer data between devices" + ] + }, + { + "cell_type": "code", + "execution_count": 6, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "tensor([[0.7461, 0.3134],\n", + " [0.4447, 0.7793]])" + ] + }, + "execution_count": 6, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "t= torch.rand(2,2)\n", + "# bad way\n", + "t.cpu ()\n", + "t[0][0].item()\n", + "t. numpy ()\n", + "\n", + "# good way\n", + "t.detach ()" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "Create tensor direclty on GPU" + ] + }, + { + "cell_type": "code", + "execution_count": 9, + "metadata": {}, + "outputs": [], + "source": [ + "# bad way\n", + "# t = torch.rand(2,2).cuda()\n", + "\n", + "# good way\n", + "# t = torch. rand(2,2, device=\"cuda\")" + ] + }, { "cell_type": "code", "execution_count": null, @@ -1758,7 +1843,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.10.8" + "version": "3.11.4" }, "orig_nbformat": 4 }, From f4162966e561a3e85353b6f6b00f068075c58f19 Mon Sep 17 00:00:00 2001 From: Ikram Ali Date: Sun, 15 Oct 2023 18:46:36 +0500 Subject: [PATCH 5/6] d --- docs/index.rst | 1 + docs/torch/pytorch_transfomers.ipynb | 23 +++++++++++++++++++++++ 2 files changed, 24 insertions(+) create mode 100644 docs/torch/pytorch_transfomers.ipynb diff --git a/docs/index.rst b/docs/index.rst index 1b4a156..66dc97a 100644 --- a/docs/index.rst +++ b/docs/index.rst @@ -93,6 +93,7 @@ Contents torch/pytorch_fundamental.ipynb torch/pytorch_workflow.ipynb torch/pytorch_neural_network_classification.ipynb + torch/pytorch_transformers.ipynb .. toctree:: :caption: Recommendation System diff --git a/docs/torch/pytorch_transfomers.ipynb b/docs/torch/pytorch_transfomers.ipynb new file mode 100644 index 0000000..e214cd1 --- /dev/null +++ b/docs/torch/pytorch_transfomers.ipynb @@ -0,0 +1,23 @@ +{ + "cells": [ + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# Pytorch Transformer Implementation\n" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [] + } + ], + "metadata": { + "language_info": { + "name": "python" + } + }, + "nbformat": 4, + "nbformat_minor": 2 +} From d841da3881ce22ecdee3d3a3dc9f616aa58dc671 Mon Sep 17 00:00:00 2001 From: Ikram Ali Date: Tue, 12 Mar 2024 13:28:21 +0500 Subject: [PATCH 6/6] New changes --- docs/requirements.txt | 12 ++++++------ requirements.txt | 2 +- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/docs/requirements.txt b/docs/requirements.txt index af5fe9c..4cb3ebf 100644 --- a/docs/requirements.txt +++ b/docs/requirements.txt @@ -1,12 +1,12 @@ -torch~=2.1 +torch~=2.2 seaborn~=0.13 -scipy~=1.11 -scikit-learn~=1.3 -torchmetrics~=1.2 -myst-nb~=0.17 +scipy~=1.12 +scikit-learn~=1.4 +torchmetrics~=1.3 +myst-nb~=1.0 sphinx-design~=0.5 sphinx-copybutton xlrd~=2.0 scikit-surprise~=1.1 -networkx~=3.1 +networkx~=3.2 gensim~=4.3 \ No newline at end of file diff --git a/requirements.txt b/requirements.txt index 5f88124..1db4d1b 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,4 +1,4 @@ -Sphinx~=5.3 +Sphinx~=7.2 -r docs/requirements.txt sphinx_rtd_theme sphinx-autobuild \ No newline at end of file