jupyter wanted so save some more
parent
a72efa44c2
commit
87567d59bd
|
|
@ -38,7 +38,7 @@
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"cell_type": "code",
|
"cell_type": "code",
|
||||||
"execution_count": null,
|
"execution_count": 38,
|
||||||
"id": "b75ac9e4",
|
"id": "b75ac9e4",
|
||||||
"metadata": {},
|
"metadata": {},
|
||||||
"outputs": [],
|
"outputs": [],
|
||||||
|
|
@ -53,6 +53,8 @@
|
||||||
" N = X.shape[1]\n",
|
" N = X.shape[1]\n",
|
||||||
" net = np.zeros(N)\n",
|
" net = np.zeros(N)\n",
|
||||||
" # self._W.shape (1,2) X.shape (2,4)\n",
|
" # self._W.shape (1,2) X.shape (2,4)\n",
|
||||||
|
" print(X.shape)\n",
|
||||||
|
" print(self._W.shape)\n",
|
||||||
" net = self._W @ X \n",
|
" net = self._W @ X \n",
|
||||||
" # b verwenden ...\n",
|
" # b verwenden ...\n",
|
||||||
" net = net - self._b\n",
|
" net = net - self._b\n",
|
||||||
|
|
@ -86,7 +88,7 @@
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"cell_type": "code",
|
"cell_type": "code",
|
||||||
"execution_count": 36,
|
"execution_count": 39,
|
||||||
"id": "ea7529b2",
|
"id": "ea7529b2",
|
||||||
"metadata": {},
|
"metadata": {},
|
||||||
"outputs": [],
|
"outputs": [],
|
||||||
|
|
@ -100,7 +102,7 @@
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"cell_type": "code",
|
"cell_type": "code",
|
||||||
"execution_count": 37,
|
"execution_count": 40,
|
||||||
"id": "c3166860",
|
"id": "c3166860",
|
||||||
"metadata": {},
|
"metadata": {},
|
||||||
"outputs": [
|
"outputs": [
|
||||||
|
|
@ -109,20 +111,22 @@
|
||||||
"output_type": "stream",
|
"output_type": "stream",
|
||||||
"text": [
|
"text": [
|
||||||
"(100,)\n",
|
"(100,)\n",
|
||||||
"(100, 2)\n"
|
"(100, 2)\n",
|
||||||
|
"(100, 2)\n",
|
||||||
|
"(1, 2)\n"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"ename": "IndexError",
|
"ename": "ValueError",
|
||||||
"evalue": "index 2 is out of bounds for axis 1 with size 2",
|
"evalue": "matmul: Input operand 1 has a mismatch in its core dimension 0, with gufunc signature (n?,k),(k,m?)->(n?,m?) (size 100 is different from 2)",
|
||||||
"output_type": "error",
|
"output_type": "error",
|
||||||
"traceback": [
|
"traceback": [
|
||||||
"\u001b[31m---------------------------------------------------------------------------\u001b[39m",
|
"\u001b[31m---------------------------------------------------------------------------\u001b[39m",
|
||||||
"\u001b[31mIndexError\u001b[39m Traceback (most recent call last)",
|
"\u001b[31mValueError\u001b[39m Traceback (most recent call last)",
|
||||||
"\u001b[36mCell\u001b[39m\u001b[36m \u001b[39m\u001b[32mIn[37]\u001b[39m\u001b[32m, line 5\u001b[39m\n\u001b[32m 1\u001b[39m \u001b[38;5;66;03m# 4d)\u001b[39;00m\n\u001b[32m 2\u001b[39m print(T.shape)\n\u001b[32m 3\u001b[39m print(X.shape)\n\u001b[32m 4\u001b[39m sln = SLN(\u001b[32m2\u001b[39m,\u001b[32m1\u001b[39m)\n\u001b[32m----> \u001b[39m\u001b[32m5\u001b[39m sln.DeltaTrain(X,T,\u001b[32m0.5\u001b[39m,\u001b[32m1000\u001b[39m,\u001b[32m0.2\u001b[39m)\n",
|
"\u001b[36mCell\u001b[39m\u001b[36m \u001b[39m\u001b[32mIn[40]\u001b[39m\u001b[32m, line 5\u001b[39m\n\u001b[32m 1\u001b[39m \u001b[38;5;66;03m# 4d)\u001b[39;00m\n\u001b[32m 2\u001b[39m print(T.shape)\n\u001b[32m 3\u001b[39m print(X.shape)\n\u001b[32m 4\u001b[39m sln = SLN(\u001b[32m2\u001b[39m,\u001b[32m1\u001b[39m)\n\u001b[32m----> \u001b[39m\u001b[32m5\u001b[39m sln.DeltaTrain(X,T,\u001b[32m0.5\u001b[39m,\u001b[32m1000\u001b[39m,\u001b[32m0.2\u001b[39m)\n",
|
||||||
"\u001b[36mCell\u001b[39m\u001b[36m \u001b[39m\u001b[32mIn[35]\u001b[39m\u001b[32m, line 24\u001b[39m, in \u001b[36mSLN.DeltaTrain\u001b[39m\u001b[34m(self, X, T, eta, maxIter, maxErrorRate)\u001b[39m\n\u001b[32m 20\u001b[39m \u001b[38;5;28;01mdef\u001b[39;00m DeltaTrain(self, X, T, eta, maxIter, maxErrorRate):\n\u001b[32m 21\u001b[39m N=X.shape[\u001b[32m1\u001b[39m] \u001b[38;5;66;03m# Anzahl Trainingsdaten\u001b[39;00m\n\u001b[32m 22\u001b[39m plt.ion() \u001b[38;5;66;03m# interactive mode on\u001b[39;00m\n\u001b[32m 23\u001b[39m \u001b[38;5;28;01mfor\u001b[39;00m it \u001b[38;5;28;01min\u001b[39;00m range(maxIter):\n\u001b[32m---> \u001b[39m\u001b[32m24\u001b[39m Y = self.neuron(X) \u001b[38;5;66;03m# nur ein Aufruf\u001b[39;00m\n\u001b[32m 25\u001b[39m err = ErrorRate(Y, T)\n\u001b[32m 26\u001b[39m \u001b[38;5;28;01mif\u001b[39;00m (it%\u001b[32m20\u001b[39m) == \u001b[32m0\u001b[39m:\n\u001b[32m 27\u001b[39m print(\u001b[33m'#{} err:{}\\n{}\\n{}'\u001b[39m.format(it,err,self._W,self._b))\n",
|
"\u001b[36mCell\u001b[39m\u001b[36m \u001b[39m\u001b[32mIn[38]\u001b[39m\u001b[32m, line 22\u001b[39m, in \u001b[36mSLN.DeltaTrain\u001b[39m\u001b[34m(self, X, T, eta, maxIter, maxErrorRate)\u001b[39m\n\u001b[32m 18\u001b[39m \u001b[38;5;28;01mdef\u001b[39;00m DeltaTrain(self, X, T, eta, maxIter, maxErrorRate):\n\u001b[32m 19\u001b[39m N=X.shape[\u001b[32m1\u001b[39m] \u001b[38;5;66;03m# Anzahl Trainingsdaten\u001b[39;00m\n\u001b[32m 20\u001b[39m plt.ion() \u001b[38;5;66;03m# interactive mode on\u001b[39;00m\n\u001b[32m 21\u001b[39m \u001b[38;5;28;01mfor\u001b[39;00m it \u001b[38;5;28;01min\u001b[39;00m range(maxIter):\n\u001b[32m---> \u001b[39m\u001b[32m22\u001b[39m Y = self.neuron(X) \u001b[38;5;66;03m# nur ein Aufruf\u001b[39;00m\n\u001b[32m 23\u001b[39m err = ErrorRate(Y, T)\n\u001b[32m 24\u001b[39m \u001b[38;5;28;01mif\u001b[39;00m (it%\u001b[32m20\u001b[39m) == \u001b[32m0\u001b[39m:\n\u001b[32m 25\u001b[39m print(\u001b[33m'#{} err:{}\\n{}\\n{}'\u001b[39m.format(it,err,self._W,self._b))\n",
|
||||||
"\u001b[36mCell\u001b[39m\u001b[36m \u001b[39m\u001b[32mIn[35]\u001b[39m\u001b[32m, line 15\u001b[39m, in \u001b[36mSLN.neuron\u001b[39m\u001b[34m(self, X)\u001b[39m\n\u001b[32m 11\u001b[39m \u001b[38;5;66;03m# net = self._W @ X\u001b[39;00m\n\u001b[32m 12\u001b[39m \u001b[38;5;28;01mfor\u001b[39;00m n \u001b[38;5;28;01min\u001b[39;00m range(N):\n\u001b[32m 13\u001b[39m \u001b[38;5;28;01mfor\u001b[39;00m j \u001b[38;5;28;01min\u001b[39;00m range(X.shape[\u001b[32m0\u001b[39m]):\n\u001b[32m 14\u001b[39m \u001b[38;5;66;03m# print(self._W)\u001b[39;00m\n\u001b[32m---> \u001b[39m\u001b[32m15\u001b[39m net[n]+= X[j,n] * self._W[\u001b[32m0\u001b[39m, j]\n\u001b[32m 16\u001b[39m \u001b[38;5;66;03m# b verwenden ...\u001b[39;00m\n\u001b[32m 17\u001b[39m net = net - self._b\n\u001b[32m 18\u001b[39m \u001b[38;5;28;01mreturn\u001b[39;00m net > \u001b[32m0\u001b[39m \u001b[38;5;66;03m# threshold ....\u001b[39;00m\n",
|
"\u001b[36mCell\u001b[39m\u001b[36m \u001b[39m\u001b[32mIn[38]\u001b[39m\u001b[32m, line 13\u001b[39m, in \u001b[36mSLN.neuron\u001b[39m\u001b[34m(self, X)\u001b[39m\n\u001b[32m 9\u001b[39m net = np.zeros(N)\n\u001b[32m 10\u001b[39m \u001b[38;5;66;03m# self._W.shape (1,2) X.shape (2,4)\u001b[39;00m\n\u001b[32m 11\u001b[39m print(X.shape)\n\u001b[32m 12\u001b[39m print(self._W.shape)\n\u001b[32m---> \u001b[39m\u001b[32m13\u001b[39m net = self._W @ X\n\u001b[32m 14\u001b[39m \u001b[38;5;66;03m# b verwenden ...\u001b[39;00m\n\u001b[32m 15\u001b[39m net = net - self._b\n\u001b[32m 16\u001b[39m \u001b[38;5;28;01mreturn\u001b[39;00m net > \u001b[32m0\u001b[39m \u001b[38;5;66;03m# threshold ....\u001b[39;00m\n",
|
||||||
"\u001b[31mIndexError\u001b[39m: index 2 is out of bounds for axis 1 with size 2"
|
"\u001b[31mValueError\u001b[39m: matmul: Input operand 1 has a mismatch in its core dimension 0, with gufunc signature (n?,k),(k,m?)->(n?,m?) (size 100 is different from 2)"
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue