{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# Network Improvements\n", "\n", "The class **`nengolib.Network()`** is intended to serve as a drop-in replacement for **`nengo.Network()`**. This new class:\n", "\n", "* samples `encoders` more uniformly;\n", "* samples `eval_points` more uniformly; and\n", "* uses neurons which spike at the ideal rate regardless of `dt` (see [Nengo #975](https://github.com/nengo/nengo/pull/975); default in `nengo>=2.1.1`).\n", "\n", "As a result, the performance of ensembles should increase, both in terms of their representational quality (the encoders become better \"representatives\") and the generalization error from the decoders (their approximation error on unseen test points). A current limitation is that the improvement only occurs for up to 40-dimensional ensembles (beyond this the original implementation is used)." ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "%pylab inline\n", "import pylab\n", "try:\n", " import seaborn as sns # optional; prettier graphs\n", "except ImportError:\n", " pass\n", "\n", "import nengo\n", "import nengolib\n", "\n", "def plot_points(module, n_neurons=100):\n", " with module.Network() as model:\n", " x = nengo.Ensemble(n_neurons, 2)\n", " nengo.Connection(x, nengo.Node(size_in=2))\n", " sim = nengo.Simulator(model)\n", "\n", " fig, ax = pylab.subplots(1, 2, sharey=True, figsize=(9, 4))\n", " ax[0].scatter(*sim.data[x].encoders.T)\n", " ax[1].scatter(*sim.data[x].eval_points.T)\n", " module = module.__name__.split('.', 1)[0]\n", " ax[0].set_title('%s Encoders' % module)\n", " ax[1].set_title('%s Eval Points' % module)\n", " pylab.show()\n", "\n", "plot_points(nengo)\n", "plot_points(nengolib)" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": true }, "outputs": [], "source": [] } ], "metadata": { "kernelspec": { "display_name": "Python 3", "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.6.5" } }, "nbformat": 4, "nbformat_minor": 2 }