-
-
Save philippjfr/3995537 to your computer and use it in GitHub Desktop.
Displaying activity in IPython notebook
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"metadata": { | |
"name": "Better Activity 2" | |
}, | |
"nbformat": 3, | |
"nbformat_minor": 0, | |
"worksheets": [ | |
{ | |
"cells": [ | |
{ | |
"cell_type": "code", | |
"collapsed": false, | |
"input": [ | |
"import topo" | |
], | |
"language": "python", | |
"metadata": {}, | |
"outputs": [], | |
"prompt_number": 2 | |
}, | |
{ | |
"cell_type": "code", | |
"collapsed": false, | |
"input": [ | |
"%run -i ./examples/gcal.ty" | |
], | |
"language": "python", | |
"metadata": {}, | |
"outputs": [], | |
"prompt_number": 3 | |
}, | |
{ | |
"cell_type": "code", | |
"collapsed": false, | |
"input": [ | |
"topo.sim.V1" | |
], | |
"language": "python", | |
"metadata": {}, | |
"outputs": [ | |
{ | |
"output_type": "pyout", | |
"prompt_number": 4, | |
"text": [ | |
"LISSOM(allow_skip_non_responding_units=True, apply_output_fns=True, beginning_of_iteration=[], continuous_learning=False, end_of_iteration=[], joint_norm_fn=<function compute_joint_norm_totals_opt at 0x389b758>, layout_location=(300, 100), mask=SheetMask(name='SheetMask00102', print_level=100), mask_init_time=5, measure_maps=True, name='V1', nominal_bounds=BoundingBox(radius=0.5), nominal_density=48.0, output_fns=[HomeostaticResponse(learning_rate=0.01, linear_slope=1.0, name='HomeostaticResponse00100', noise_magnitude=0.10000000000000001, norm_value=None, period=1.0, plastic=True, print_level=100, randomized_init=False, seed=42, smoothing=0.99099999999999999, t_init=0.14999999999999999, target_activity=0.024)], plastic=True, post_initialization_weights_output_fns=[], precedence=0.59999999999999998, print_level=100, row_precedence=0.5, strict_tsettle=None, tsettle=16)" | |
] | |
} | |
], | |
"prompt_number": 4 | |
}, | |
{ | |
"cell_type": "code", | |
"collapsed": false, | |
"input": [ | |
"def imact(objs, size=1.0, show_axes=False, label_name=True, norm_type=0, fig={},\n", | |
" show={'interpolation':'nearest', 'cmap':plt.cm.gray}):\n", | |
" \"\"\"\n", | |
" Displays the activity array of the given list of objects in row format.\n", | |
"\n", | |
" size: An overall size factor.\n", | |
" show_axes: Whether or not to show axes for each subplot.\n", | |
" label_name: Show the object name above the subplot\n", | |
" norm_type: 0:No normalization, 1:Individually, 2: Together.\n", | |
"\n", | |
" fig: Extra kwargs for the pyplot figure.\n", | |
" show: Extra kwargs for imshow. Note: norm will override norm_type if set.\n", | |
" \"\"\"\n", | |
"\n", | |
" fig = plt.figure(*fig)\n", | |
" (width, height) = fig.get_figwidth(), fig.get_figheight()\n", | |
" fig.set_figwidth(width*size)\n", | |
" fig.set_figheight(height*size)\n", | |
" \n", | |
" if norm==1:\n", | |
" show= dict({'norm':matplotlib.colors.Normalize()}, **show)\n", | |
" if norm==2:\n", | |
" activities = [obj.activity for obj in objs]\n", | |
" vmax = min(act.max() for act in activities)\n", | |
" vmin = min(act.min() for act in activities)\n", | |
" show= dict({'norm':matplotlib.colors.Normalize(vmin=vmin, vmax=vmax)}, **show)\n", | |
"\n", | |
" plot_num = len(objs)\n", | |
" for (i, obj) in enumerate(objs):\n", | |
" ax = plt.subplot(1,plot_num,i)\n", | |
" if label_name: plt.title(obj.name)\n", | |
" if not show_axes:\n", | |
" ax.yaxis.set_visible(False)\n", | |
" ax.xaxis.set_visible(False)\n", | |
" imshow(obj.activity, **show)" | |
], | |
"language": "python", | |
"metadata": {}, | |
"outputs": [], | |
"prompt_number": 5 | |
}, | |
{ | |
"cell_type": "code", | |
"collapsed": false, | |
"input": [ | |
"topo.sim.run(1)\n", | |
"imact([topo.sim.V1,topo.sim.Retina])" | |
], | |
"language": "python", | |
"metadata": {}, | |
"outputs": [ | |
{ | |
"output_type": "display_data", | |
"png": "iVBORw0KGgoAAAANSUhEUgAAAV0AAAC1CAYAAAD86CzsAAAABHNCSVQICAgIfAhkiAAAAAlwSFlz\nAAALEgAACxIB0t1+/AAAD3dJREFUeJzt3W1o1fUbx/HP2brbcs7J5jRrLpvLyJuCFEtGmRgDsaJo\nRMYW0YPAGj2L8kFB+aSCIDAI6snyQXcgUoaRJmsIYYRUFEtTly7tRqfurs2Z5//A//U71/npmWs3\n37Nz9n5BnO/O/O38Tju7zvW7zvX9fhPJZDIpAEAQBdk+AQCYSgi6ABAQQRcAAiLoAkBABF0ACIig\nCwABEXTHWUlJiTo6OrJ9GgAmKYKupOrqahUXF6ukpERlZWVqaGhQV1fXZY+755579N5776Xd19PT\no+rq6gk6U2Bi1NfX66WXXrro/m3btmnOnDnauXOnVq1apRkzZujGG2/MwhnmD4KupEQioc8++0w9\nPT1qb2/X/v379fLLL4/oOCAfPPHEE9qyZctF97///vt6/PHHVVpaqqeeekqvv/56Fs4uvxB0Yyor\nK3XffffpwIEDkqSvvvpKt99+u6ZPn66FCxdqx44dkqSNGzeqra1NzzzzjEpKStTc3CxJKigo0KFD\nhyRdeCFv2LBB69atU0lJiW677Tbt378/eqwNGzZo7ty5mjZtmhYvXqxdu3YFfrbABQ888IBOnjyp\ntra26L5Tp05p+/btamxs1LJly7R+/Xqy3HFA0P0/mw3d2dmpHTt26M4779TBgwf18MMP64033lB3\nd7feeecdPfroozp+/Lg2bdqkuro6bd68WT09PXrrrbcu+XM//PBDbdq0SadPn9aiRYv0wgsvRN+7\n++679csvv6i3t1dPP/20HnnkEQ0MDAR5voBXVFSkhoYGtbS0RPd99NFHuuWWW7R48eIsnln+Iejq\nQsB98MEHNX36dFVVVemmm27Sxo0btWXLFq1bt06rV6+WdCFIrlixQp9++mnasZkkEgk99NBDWrJk\niQoLC7V+/Xp9//330fcbGho0bdo0SRey3sLCQv34448T9CyB4TU1NemTTz7R2bNnJUktLS1qamrK\n8lnlH4KuLgTHbdu2qbu7W62trdq9e7e+++47dXZ26uOPP1ZZWVn03549e9I+ZLtcXbeysjIaFxUV\naXBwMPr6lVde0YIFC1RaWqqysjJ1dXWpt7d3/J8gMAIrV65UeXm5tm7dqoMHD+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nsl/b1y9+M1L+tT3VruzyLujGywnW92i39n17AdsLzv4I7MVot5dbzNwCZH9/v06cOCEpVT6wZSPt\n1gK8vcjiJY9M5QWCL5A/KC8AQEB5k+nGtzW32/j0X2uDiS8BGV84fKQbVPqfE19O0tpsrMRh2bZ9\nHd8s08TPfTJsG4+x81vW+Flg/vI8XlIYT74dzc82y7QN0HBbuI/16ss/T78YTqaFcPIJmS4ABJQ3\nma6JZ7D2jhzPcCcyi4yfQzwDjmfl8Xnp8Z8T/z4ZL5C78i7oApOVvyT3JQVfdvBvsCPdI89fnvs3\n5PjxvmPCL6zjH9N3LPiyw0i32xmNqVBS8PIm6Mazv8lYB42fU7wulinjjR8PIHdR0wWAgPIm0zW5\nnA3m8rlj9MbaCeCP92O/qIyUXsbwJQlf6vCX+n7BGz9pQhp56QMXI9MFgIAIugAQUCKZ4Zr2ch/q\nAGOVrXLKVHlt+3KClF568Ov5+jKC/ze5vONutg33/4tMFwACIugCQECUF5A1lBfGx1jLAL4MwYp2\n44PyAgBMEgRdAAiIoAsAAeXdjDRgqhlrbZw6blhkugAQEEEXAAIi6AJAQARdAAiIoAsAARF0ASAg\ngi4ABETQBYCACLoAEBBBFwACIugCQEAEXQAIiKALAAERdAEgIIIuAARE0AWAgAi6ABAQQRcAAiLo\nAkBABF0ACIigCwABEXQBICCCLgAERNAFgIAIugAQEEEXAAIi6AJAQARdAAiIoAsAARF0ASAggi4A\nBETQBYCACLoAEBBBFwACIugCQEAEXQAIiKALAAERdAEgIIIuAARE0AWAgAi6ABAQQRcAAiLoAkBA\nBF0ACIigCwABEXQBICCCLgAERNAFgIAIugAQEEEXAAIi6AJAQARdAAiIoAsAARF0ASAggi4ABETQ\nBYCAEslkMpntkwCAqYJMFwACIugCQEAEXQAIiKALAAERdAEgIIIuAAT0P0FtSH18ZtovAAAAAElF\nTkSuQmCC\n" | |
} | |
], | |
"prompt_number": 20 | |
}, | |
{ | |
"cell_type": "code", | |
"collapsed": false, | |
"input": [ | |
"topo.sim." | |
], | |
"language": "python", | |
"metadata": {}, | |
"outputs": [] | |
} | |
], | |
"metadata": {} | |
} | |
] | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment