From 459d09f379aace0d48648384429329d72ec7d13f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pawe=C5=82=20Sk=C3=B3rzewski?= Date: Fri, 5 Mar 2021 08:21:24 +0100 Subject: [PATCH] =?UTF-8?q?Zmiana=20nazw=20plik=C3=B3w?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lab/{2001_Python.ipynb => 01_Python.ipynb} | 919 +++++++++++++++++- ..._Wczytywanie_i_prezentowanie_danych.ipynb} | 0 ...iniowa.ipynb => 03_Regresja_liniowa.ipynb} | 0 ...ikit-learn.ipynb => 07_scikit-learn.ipynb} | 0 ...uronowe.ipynb => 10_Sieci_neuronowe.ipynb} | 0 ...> 11_Wielowarstwowe_sieci_neuronowe.ipynb} | 0 ...powadzenie.ipynb => 01_Wprowadzenie.ipynb} | 11 - 7 files changed, 882 insertions(+), 48 deletions(-) rename lab/{2001_Python.ipynb => 01_Python.ipynb} (63%) rename lab/{2002_Wczytywanie_i_prezentowanie_danych.ipynb => 02_Wczytywanie_i_prezentowanie_danych.ipynb} (100%) rename lab/{2003_Regresja_liniowa.ipynb => 03_Regresja_liniowa.ipynb} (100%) rename lab/{2007_scikit-learn.ipynb => 07_scikit-learn.ipynb} (100%) rename lab/{2010_Sieci_neuronowe.ipynb => 10_Sieci_neuronowe.ipynb} (100%) rename lab/{2011_Wielowarstwowe_sieci_neuronowe.ipynb => 11_Wielowarstwowe_sieci_neuronowe.ipynb} (100%) rename wyk/{01_Wrpowadzenie.ipynb => 01_Wprowadzenie.ipynb} (99%) diff --git a/lab/2001_Python.ipynb b/lab/01_Python.ipynb similarity index 63% rename from lab/2001_Python.ipynb rename to lab/01_Python.ipynb index 5aebe15..60bb260 100644 --- a/lab/2001_Python.ipynb +++ b/lab/01_Python.ipynb @@ -8,8 +8,8 @@ } }, "source": [ - "## Uczenie maszynowe 2019/2020 – laboratoria\n", - "### 2/3 marca 2020\n", + "## Uczenie maszynowe 2020/2021 – laboratoria\n", + "### 3 marca 2021\n", "# 1. Python – listy składane, indeksowanie, biblioteka _NumPy_" ] }, @@ -20,6 +20,45 @@ "## Listy składane (*List comprehension*)" ] }, + { + "cell_type": "code", + "execution_count": 78, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "[1, 4, 9, 16, 25, 36, 49, 64, 81, 100]\n" + ] + } + ], + "source": [ + "lista = []\n", + "for x in range(1, 11):\n", + " lista.append(x ** 2)\n", + " \n", + "print(lista)" + ] + }, + { + "cell_type": "code", + "execution_count": 79, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "[1, 4, 9, 16, 25, 36, 49, 64, 81, 100]\n" + ] + } + ], + "source": [ + "lista = [x ** 2 for x in range(1, 11)]\n", + "print(lista)" + ] + }, { "cell_type": "markdown", "metadata": {}, @@ -27,6 +66,143 @@ "Przypuśćmy, że mamy dane zdanie i chcemy utworzyć listę, która będzie zawierać długości kolejnych wyrazów tego zdania. Możemy to zrobić w następujący sposób:" ] }, + { + "cell_type": "code", + "execution_count": 16, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "[4, 16, 36, 64, 100]\n" + ] + } + ], + "source": [ + "lista = []\n", + "for i in range(1, 11):\n", + " if i % 2 == 0:\n", + " lista.append(i ** 2)\n", + " \n", + "print(lista)" + ] + }, + { + "cell_type": "code", + "execution_count": 15, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "[4, 16, 36, 64, 100]\n" + ] + } + ], + "source": [ + "lista = [i ** 2 for i in range(1, 11) if i % 2 == 0]\n", + "print(lista)" + ] + }, + { + "cell_type": "code", + "execution_count": 5, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "[1, 2, 3, 4, 5, 6, 7, 8, 9, 10]" + ] + }, + "execution_count": 5, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "list(range(1, 11))" + ] + }, + { + "cell_type": "code", + "execution_count": 80, + "metadata": { + "scrolled": true + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "tracz tarł tarcicę tak takt w takt jak takt w takt tarcicę tartak tarł\n" + ] + } + ], + "source": [ + "zdanie = 'tracz tarł tarcicę tak takt w takt jak takt w takt tarcicę tartak tarł'\n", + "print(zdanie)" + ] + }, + { + "cell_type": "code", + "execution_count": 81, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "['tracz', 'tarł', 'tarcicę', 'tak', 'takt', 'w', 'takt', 'jak', 'takt', 'w', 'takt', 'tarcicę', 'tartak', 'tarł']\n" + ] + } + ], + "source": [ + "wyrazy = zdanie.split()\n", + "print(wyrazy)" + ] + }, + { + "cell_type": "code", + "execution_count": 82, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "[5, 4, 7, 3, 4, 1, 4, 3, 4, 1, 4, 7, 6, 4]\n" + ] + } + ], + "source": [ + "dlugosci_wyrazow = []\n", + "for wyraz in wyrazy:\n", + " dlugosci_wyrazow.append(len(wyraz))\n", + " \n", + "print(dlugosci_wyrazow)" + ] + }, + { + "cell_type": "code", + "execution_count": 83, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "[5, 4, 7, 3, 4, 1, 4, 3, 4, 1, 4, 7, 6, 4]\n" + ] + } + ], + "source": [ + "dlugosci_wyrazow = [len(wyraz) for wyraz in wyrazy]\n", + "print(dlugosci_wyrazow)" + ] + }, { "cell_type": "code", "execution_count": 1, @@ -59,7 +235,7 @@ }, { "cell_type": "code", - "execution_count": 2, + "execution_count": 84, "metadata": {}, "outputs": [ { @@ -72,8 +248,7 @@ ], "source": [ "zdanie = 'tracz tarł tarcicę tak takt w takt jak takt w takt tarcicę tartak tarł'\n", - "wyrazy = zdanie.split()\n", - "dlugosci_wyrazow = [len(wyraz) for wyraz in wyrazy]\n", + "dlugosci_wyrazow = [len(wyraz) for wyraz in zdanie.split()]\n", "\n", "print(dlugosci_wyrazow)" ] @@ -121,7 +296,7 @@ }, { "cell_type": "code", - "execution_count": 4, + "execution_count": 85, "metadata": {}, "outputs": [ { @@ -148,7 +323,7 @@ }, { "cell_type": "code", - "execution_count": 5, + "execution_count": 86, "metadata": {}, "outputs": [ { @@ -177,7 +352,7 @@ }, { "cell_type": "code", - "execution_count": 6, + "execution_count": 21, "metadata": {}, "outputs": [ { @@ -205,6 +380,23 @@ "print(napis[:]) # 'abcde' (kopia całego napisu)" ] }, + { + "cell_type": "code", + "execution_count": 88, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "abcde\n" + ] + } + ], + "source": [ + "print(napis[:])" + ] + }, { "cell_type": "markdown", "metadata": {}, @@ -236,7 +428,30 @@ }, { "cell_type": "code", - "execution_count": 7, + "execution_count": 91, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "[[1 2 3]\n", + " [4 5 6]\n", + " [7 8 9]]\n" + ] + } + ], + "source": [ + "import numpy as np\n", + "\n", + "A = np.array([[1, 2, 3], [4, 5, 6], [7, 8, 9]])\n", + "\n", + "print(A)" + ] + }, + { + "cell_type": "code", + "execution_count": 97, "metadata": {}, "outputs": [ { @@ -256,6 +471,119 @@ "print(x)" ] }, + { + "cell_type": "code", + "execution_count": 98, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "[[ 1. 2. 3. -4.5 5. ]\n", + " [ 10. 9. -8. -13. 0.39]]\n" + ] + } + ], + "source": [ + "import numpy as np\n", + "\n", + "y = np.array([[1, 2, 3, -4.5, 5], [10, 9, -8, -13, 0.39]])\n", + "print(y)" + ] + }, + { + "cell_type": "code", + "execution_count": 99, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "(3, 3)\n" + ] + } + ], + "source": [ + "print(x.shape)" + ] + }, + { + "cell_type": "code", + "execution_count": 100, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "(2, 5)\n" + ] + } + ], + "source": [ + "print(y.shape)" + ] + }, + { + "cell_type": "code", + "execution_count": 102, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "[[ 1. 2. ]\n", + " [ 3. -4.5 ]\n", + " [ 5. 10. ]\n", + " [ 9. -8. ]\n", + " [-13. 0.39]]\n" + ] + } + ], + "source": [ + "z = y.reshape(5, 2)\n", + "print(z)" + ] + }, + { + "cell_type": "code", + "execution_count": 103, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "(5, 2)\n" + ] + } + ], + "source": [ + "print(z.shape)" + ] + }, + { + "cell_type": "code", + "execution_count": 107, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "[[ 1. 2. 3. -4.5 5. ]\n", + " [ 10. 9. -8. -13. 0.39]]\n" + ] + } + ], + "source": [ + "w = z.reshape(2, 5)\n", + "print(w)" + ] + }, { "cell_type": "markdown", "metadata": {}, @@ -265,22 +593,146 @@ }, { "cell_type": "code", - "execution_count": 8, + "execution_count": 39, "metadata": {}, "outputs": [ { - "data": { - "text/plain": [ - "(3, 3)" - ] - }, - "execution_count": 8, - "metadata": {}, - "output_type": "execute_result" + "name": "stdout", + "output_type": "stream", + "text": [ + "(2, 5)\n", + "[[ 1. 2. ]\n", + " [ 3. 4. ]\n", + " [ 5. 10. ]\n", + " [ 9. 8. ]\n", + " [-13. 0.39]]\n", + "(5, 2)\n" + ] } ], "source": [ - "x.shape" + "print(y.shape)\n", + "\n", + "z = y.reshape((5, 2))\n", + "print(z)\n", + "print(z.shape)" + ] + }, + { + "cell_type": "code", + "execution_count": 108, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "[[ 1. 2. ]\n", + " [ 3. -4.5 ]\n", + " [ 5. 10. ]\n", + " [ 9. -8. ]\n", + " [-13. 0.39]]\n" + ] + } + ], + "source": [ + "print(z)" + ] + }, + { + "cell_type": "code", + "execution_count": 115, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "[ 3. -1.5 15. 1. -12.61]\n" + ] + } + ], + "source": [ + "print(z.sum(axis=1))" + ] + }, + { + "cell_type": "code", + "execution_count": 45, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "[[1 2 3]\n", + " [4 5 6]\n", + " [7 8 9]]\n", + "[2. 5. 8.]\n" + ] + } + ], + "source": [ + "print(x)\n", + "print(x.mean(axis=1))" + ] + }, + { + "cell_type": "code", + "execution_count": 119, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "[ 1 2 3 4 5 6 7 8 9 10]\n" + ] + } + ], + "source": [ + "lista = list(range(1, 11))\n", + "A = np.array(lista)\n", + "print(A)" + ] + }, + { + "cell_type": "code", + "execution_count": 47, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "[1, 2, 3, 4, 5, 6, 7, 8, 9, 10]\n", + "[ 1 2 3 4 5 6 7 8 9 10]\n" + ] + } + ], + "source": [ + "lista = list(range(1, 11))\n", + "print(lista)\n", + "A = np.array(lista)\n", + "print(A)" + ] + }, + { + "cell_type": "code", + "execution_count": 120, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "[ 1 2 3 4 5 6 7 8 9 10]\n" + ] + } + ], + "source": [ + "A = np.arange(1, 11)\n", + "print(A)" ] }, { @@ -352,42 +804,51 @@ }, { "cell_type": "code", - "execution_count": 12, + "execution_count": 121, "metadata": {}, "outputs": [ { "data": { "text/plain": [ - "array([5, 6, 7, 8, 9])" + "array([ 5, 6, 7, 8, 9, 10, 11, 12, 13, 14])" ] }, - "execution_count": 12, + "execution_count": 121, "metadata": {}, "output_type": "execute_result" } ], "source": [ - "np.arange(5, 10)" + "np.arange(5, 15)" ] }, { "cell_type": "code", - "execution_count": 13, + "execution_count": 127, "metadata": {}, "outputs": [ { "data": { "text/plain": [ - "array([5. , 5.5, 6. , 6.5, 7. , 7.5, 8. , 8.5, 9. , 9.5])" + "array([[ 5. , 5.1, 5.2, 5.3, 5.4, 5.5, 5.6, 5.7, 5.8, 5.9],\n", + " [ 6. , 6.1, 6.2, 6.3, 6.4, 6.5, 6.6, 6.7, 6.8, 6.9],\n", + " [ 7. , 7.1, 7.2, 7.3, 7.4, 7.5, 7.6, 7.7, 7.8, 7.9],\n", + " [ 8. , 8.1, 8.2, 8.3, 8.4, 8.5, 8.6, 8.7, 8.8, 8.9],\n", + " [ 9. , 9.1, 9.2, 9.3, 9.4, 9.5, 9.6, 9.7, 9.8, 9.9],\n", + " [10. , 10.1, 10.2, 10.3, 10.4, 10.5, 10.6, 10.7, 10.8, 10.9],\n", + " [11. , 11.1, 11.2, 11.3, 11.4, 11.5, 11.6, 11.7, 11.8, 11.9],\n", + " [12. , 12.1, 12.2, 12.3, 12.4, 12.5, 12.6, 12.7, 12.8, 12.9],\n", + " [13. , 13.1, 13.2, 13.3, 13.4, 13.5, 13.6, 13.7, 13.8, 13.9],\n", + " [14. , 14.1, 14.2, 14.3, 14.4, 14.5, 14.6, 14.7, 14.8, 14.9]])" ] }, - "execution_count": 13, + "execution_count": 127, "metadata": {}, "output_type": "execute_result" } ], "source": [ - "np.arange(5, 10, 0.5)" + "np.arange(5, 15, 0.1).reshape(10, 10)" ] }, { @@ -431,19 +892,20 @@ }, { "cell_type": "code", - "execution_count": 15, + "execution_count": 128, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ - "[0. 1.25 2.5 3.75 5. ]\n" + "[0. 0.22222222 0.44444444 0.66666667 0.88888889 1.11111111\n", + " 1.33333333 1.55555556 1.77777778 2. ]\n" ] } ], "source": [ - "x = np.linspace(0, 5, 5)\n", + "x = np.linspace(0, 2, 10)\n", "print(x)" ] }, @@ -517,14 +979,14 @@ }, { "cell_type": "code", - "execution_count": 17, + "execution_count": 129, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ - "int32\n", + "float64\n", "[0.1 0.2 0.3]\n", "float64\n", "float64\n" @@ -532,7 +994,7 @@ } ], "source": [ - "x = np.array([1, 2, 3])\n", + "x = np.array([1, 2, 3, 0.5])\n", "print(x.dtype)\n", "x = np.array([0.1, 0.2, 0.3])\n", "print(x)\n", @@ -550,7 +1012,7 @@ }, { "cell_type": "code", - "execution_count": 18, + "execution_count": 135, "metadata": {}, "outputs": [ { @@ -570,7 +1032,7 @@ }, { "cell_type": "code", - "execution_count": 19, + "execution_count": 136, "metadata": {}, "outputs": [ { @@ -584,10 +1046,213 @@ } ], "source": [ - "x = np.ones([3,4])\n", + "y = np.ones([3,4])\n", + "print(y)" + ] + }, + { + "cell_type": "code", + "execution_count": 137, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "[[1. 1. 1. 1.]\n", + " [1. 1. 1. 1.]\n", + " [1. 1. 1. 1.]]\n" + ] + } + ], + "source": [ + "print(x + y)" + ] + }, + { + "cell_type": "code", + "execution_count": 138, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "[[ 0 1 2]\n", + " [ 3 4 5]\n", + " [ 6 7 8]\n", + " [ 9 10 11]]\n" + ] + } + ], + "source": [ + "x = np.arange(12).reshape(4, 3)\n", "print(x)" ] }, + { + "cell_type": "code", + "execution_count": 141, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "[[ 5 6 7]\n", + " [ 8 9 10]\n", + " [11 12 13]\n", + " [14 15 16]]\n" + ] + } + ], + "source": [ + "y = np.arange(5, 17).reshape(4, 3)\n", + "print(y)" + ] + }, + { + "cell_type": "code", + "execution_count": 144, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "[[ 0 6 14]\n", + " [ 24 36 50]\n", + " [ 66 84 104]\n", + " [126 150 176]]\n" + ] + } + ], + "source": [ + "print(x * y)" + ] + }, + { + "cell_type": "code", + "execution_count": 146, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "[[0 1 2 3]\n", + " [4 5 6 7]]\n" + ] + } + ], + "source": [ + "A = np.arange(8).reshape(2, 4)\n", + "print(A)" + ] + }, + { + "cell_type": "code", + "execution_count": 147, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "[[ 1 2 3]\n", + " [ 4 5 6]\n", + " [ 7 8 9]\n", + " [10 11 12]]\n" + ] + } + ], + "source": [ + "B = np.arange(1, 13).reshape(4, 3)\n", + "print(B)" + ] + }, + { + "cell_type": "code", + "execution_count": 148, + "metadata": { + "scrolled": true + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "(2, 4) (4, 3)\n" + ] + } + ], + "source": [ + "print(A.shape, B.shape)" + ] + }, + { + "cell_type": "code", + "execution_count": 149, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "[[ 48 54 60]\n", + " [136 158 180]]\n", + "(2, 3)\n" + ] + } + ], + "source": [ + "C = np.matmul(A, B)\n", + "print(C)\n", + "print(C.shape)" + ] + }, + { + "cell_type": "code", + "execution_count": 150, + "metadata": {}, + "outputs": [ + { + "ename": "ValueError", + "evalue": "operands could not be broadcast together with shapes (2,4) (4,3) ", + "output_type": "error", + "traceback": [ + "\u001b[1;31m---------------------------------------------------------------------------\u001b[0m", + "\u001b[1;31mValueError\u001b[0m Traceback (most recent call last)", + "\u001b[1;32m\u001b[0m in \u001b[0;36m\u001b[1;34m\u001b[0m\n\u001b[1;32m----> 1\u001b[1;33m \u001b[0mA\u001b[0m \u001b[1;33m*\u001b[0m \u001b[0mB\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m", + "\u001b[1;31mValueError\u001b[0m: operands could not be broadcast together with shapes (2,4) (4,3) " + ] + } + ], + "source": [ + "A * B" + ] + }, + { + "cell_type": "code", + "execution_count": 151, + "metadata": {}, + "outputs": [ + { + "ename": "ValueError", + "evalue": "matmul: Input operand 1 has a mismatch in its core dimension 0, with gufunc signature (n?,k),(k,m?)->(n?,m?) (size 2 is different from 4)", + "output_type": "error", + "traceback": [ + "\u001b[1;31m---------------------------------------------------------------------------\u001b[0m", + "\u001b[1;31mValueError\u001b[0m Traceback (most recent call last)", + "\u001b[1;32m\u001b[0m in \u001b[0;36m\u001b[1;34m\u001b[0m\n\u001b[1;32m----> 1\u001b[1;33m \u001b[0mnp\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mmatmul\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mA\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mC\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m", + "\u001b[1;31mValueError\u001b[0m: matmul: Input operand 1 has a mismatch in its core dimension 0, with gufunc signature (n?,k),(k,m?)->(n?,m?) (size 2 is different from 4)" + ] + } + ], + "source": [ + "np.matmul(A, C)" + ] + }, { "cell_type": "markdown", "metadata": {}, @@ -602,6 +1267,186 @@ "Operatory arytmetyczne na tablicach w NumPy działają **element po elemencie**." ] }, + { + "cell_type": "code", + "execution_count": 58, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "[[1 2 3]\n", + " [1 2 3]]\n" + ] + } + ], + "source": [ + "A = np.array([[1, 2, 3], [1, 2, 3]])\n", + "B = np.array([[4, 5, 6], [7, 8, 9]])\n", + " \n", + "print(A)" + ] + }, + { + "cell_type": "code", + "execution_count": 59, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "[[4 5 6]\n", + " [7 8 9]]\n" + ] + } + ], + "source": [ + "print(B)" + ] + }, + { + "cell_type": "code", + "execution_count": 62, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "[[-3 -3 -3]\n", + " [-6 -6 -6]]\n" + ] + } + ], + "source": [ + "print(A - B)" + ] + }, + { + "cell_type": "code", + "execution_count": 63, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "[[3 3 3]\n", + " [6 6 6]]\n" + ] + } + ], + "source": [ + "print(B - A)" + ] + }, + { + "cell_type": "code", + "execution_count": 64, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "[[ 4 10 18]\n", + " [ 7 16 27]]\n" + ] + } + ], + "source": [ + "print(A * B)" + ] + }, + { + "cell_type": "code", + "execution_count": 65, + "metadata": {}, + "outputs": [ + { + "ename": "ValueError", + "evalue": "matmul: Input operand 1 has a mismatch in its core dimension 0, with gufunc signature (n?,k),(k,m?)->(n?,m?) (size 2 is different from 3)", + "output_type": "error", + "traceback": [ + "\u001b[1;31m---------------------------------------------------------------------------\u001b[0m", + "\u001b[1;31mValueError\u001b[0m Traceback (most recent call last)", + "\u001b[1;32m\u001b[0m in \u001b[0;36m\u001b[1;34m\u001b[0m\n\u001b[1;32m----> 1\u001b[1;33m \u001b[0mnp\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mmatmul\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mA\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mB\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m", + "\u001b[1;31mValueError\u001b[0m: matmul: Input operand 1 has a mismatch in its core dimension 0, with gufunc signature (n?,k),(k,m?)->(n?,m?) (size 2 is different from 3)" + ] + } + ], + "source": [ + "np.matmul(A, B)" + ] + }, + { + "cell_type": "code", + "execution_count": 72, + "metadata": { + "scrolled": true + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "(2, 3)\n", + "(3, 4)\n", + "\n", + "[[1 2 3]\n", + " [1 2 3]]\n", + "[[1 2 3 4]\n", + " [9 8 7 6]\n", + " [2 4 6 7]]\n", + "[[25 30 35 37]\n", + " [25 30 35 37]]\n", + "\n", + "(2, 3) (3, 4)\n", + "(2, 4)\n" + ] + } + ], + "source": [ + "print(A.shape)\n", + "B = np.array([[1, 2, 3, 4], [9, 8, 7, 6], [2, 4, 6, 7]])\n", + "print(B.shape)\n", + "\n", + "print()\n", + "\n", + "print(A)\n", + "print(B)\n", + "C = np.matmul(A, B)\n", + "print(C)\n", + "\n", + "print()\n", + "\n", + "print(A.shape, B.shape)\n", + "print(C.shape)" + ] + }, + { + "cell_type": "code", + "execution_count": 73, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "array([[25, 30, 35, 37],\n", + " [25, 30, 35, 37]])" + ] + }, + "execution_count": 73, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "np.dot(A, B)" + ] + }, { "cell_type": "code", "execution_count": 20, @@ -1637,7 +2482,7 @@ " 6 \\\\\n", " \\end{array}\n", " \\right]$ oblicz wynikowy wektor: \n", - "$$ \\theta = (X^\\top \\, X)^{-1} \\, X^\\top \\, y^\\top \\, . $$\n", + "$$ \\theta = (X^\\top \\, X)^{-1} \\, X^\\top \\, y \\, . $$\n", "Wykonaj te same obliczenia raz na obiektach typu `array`, a raz na obiektach typu `matrix`.\n", "W przypadku obiektów typu `matrix` zastosuj możliwie krótki zapis. " ] diff --git a/lab/2002_Wczytywanie_i_prezentowanie_danych.ipynb b/lab/02_Wczytywanie_i_prezentowanie_danych.ipynb similarity index 100% rename from lab/2002_Wczytywanie_i_prezentowanie_danych.ipynb rename to lab/02_Wczytywanie_i_prezentowanie_danych.ipynb diff --git a/lab/2003_Regresja_liniowa.ipynb b/lab/03_Regresja_liniowa.ipynb similarity index 100% rename from lab/2003_Regresja_liniowa.ipynb rename to lab/03_Regresja_liniowa.ipynb diff --git a/lab/2007_scikit-learn.ipynb b/lab/07_scikit-learn.ipynb similarity index 100% rename from lab/2007_scikit-learn.ipynb rename to lab/07_scikit-learn.ipynb diff --git a/lab/2010_Sieci_neuronowe.ipynb b/lab/10_Sieci_neuronowe.ipynb similarity index 100% rename from lab/2010_Sieci_neuronowe.ipynb rename to lab/10_Sieci_neuronowe.ipynb diff --git a/lab/2011_Wielowarstwowe_sieci_neuronowe.ipynb b/lab/11_Wielowarstwowe_sieci_neuronowe.ipynb similarity index 100% rename from lab/2011_Wielowarstwowe_sieci_neuronowe.ipynb rename to lab/11_Wielowarstwowe_sieci_neuronowe.ipynb diff --git a/wyk/01_Wrpowadzenie.ipynb b/wyk/01_Wprowadzenie.ipynb similarity index 99% rename from wyk/01_Wrpowadzenie.ipynb rename to wyk/01_Wprowadzenie.ipynb index bb621f1..23a001a 100644 --- a/wyk/01_Wrpowadzenie.ipynb +++ b/wyk/01_Wprowadzenie.ipynb @@ -13,17 +13,6 @@ "# 1. Wprowadzenie" ] }, - { - "cell_type": "markdown", - "metadata": { - "slideshow": { - "slide_type": "slide" - } - }, - "source": [ - "https://eduwiki.wmi.amu.edu.pl" - ] - }, { "cell_type": "markdown", "metadata": {