Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix non-homogeneous array creation in snapshoot recording of training funciton #299

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
5 changes: 3 additions & 2 deletions lessons/3-NeuralNetworks/03-Perceptron/Perceptron.ipynb
Expand Up @@ -462,7 +462,8 @@
" neg_out = np.dot(negative_examples, weights) \n",
" pos_correct = (pos_out >= 0).sum() / float(pos_count)\n",
" neg_correct = (neg_out < 0).sum() / float(neg_count)\n",
" snapshots.append((np.copy(weights),(pos_correct+neg_correct)/2.0))\n",
" # make correction a list so it is homogeneous to weights list then numpy array accepts\n",
" snapshots.append((np.concatenate(weights),[(pos_correct+neg_correct)/2.0,0,0]))\n",
"\n",
" return np.array(snapshots)\n",
"\n",
Expand All @@ -476,7 +477,7 @@
" pylab.plot(np.arange(len(snapshots[:,1])), snapshots[:,1])\n",
" pylab.ylabel('Accuracy')\n",
" pylab.xlabel('Iteration')\n",
" pylab.plot(step, snapshots[step,1], \"bo\")\n",
" pylab.plot(step, snapshots[step,1][0], \"bo\")\n",
" pylab.show()\n",
"def pl1(step): plotit(pos_examples,neg_examples,snapshots,step)"
]
Expand Down