

# for i in range(0,perColumn*perRow,perColumn): # fields2 = np.vstack(] + list(fields.shape))]) Mpl.title('%s Receptive Fields' % layer.name) Grid = ImageGrid(fig,111,nrows_ncols=(perRow,perColumn),axes_pad=padding,cbar_mode='single') PerColumn = int(math.ceil(fields.shape/float(perRow)))įrom mpl_toolkits.axes_grid1 import ImageGrid PerRow = int(math.floor(math.sqrt(fields.shape))) If len(np.shape(wp)) < 4: # Fully connected layer, has no shapeįields = np.reshape(wp,list(wp.shape)+fieldShape)Įlse: # Convolutional layer already has shapeįeatures, channels, iy, ix = np.shape(wp)įields = np.reshape(wp,) Pylab.ylabel('Total Resources Generated')ĭef plotFields(layer,fieldShape=None,channel=None,figOffset=1,cmap=None,padding=0.01):

Pylab.legend(('Data Set no.1', 'Data Set no.2')) # plot in pylab (total resources over time) In the next video, we’ll learn what some of these inner workings are, and then we’ll see why relying on pyplot alone is usually a bad idea.Helper function to gain insight on provided data sets background,ĭata1 =, ,, ,, ,, ,, ]ĭata2 =, ,, ,, ,, ,, ,, ,, ,, ,, ,, ] So, then what about pyplot? Well, we shouldn’t rely on that alone either.Ġ3:32 This is because it masks a lot of the inner workings of matplotlib, inner workings that we want to have access to.

Having these functions accessible in a global namespace caused conflicts with Python’s own built-in global functions and it made it really hard to track down certain bugs.Ġ2:57 The bottom line is Matplotlib has abandoned this convenience model and now explicitly recommends against using pylab, bringing things more in line with one of Python’s key notions: explicit is always better than implicit.Ġ3:15 pylab can still be useful when creating simple graphics within an interactive shell like IPython, but we shouldn’t use it in our scripts. pylab, on the other hand, is a module within matplotlib that exists only to bring a number of functions and classes from both numpy and pyplot into the global namespace, making it easy for MATLAB users who were not used to imports to use Matplotlib.Ġ2:20 This means that all they needed was a good old from pylab import * at the top of their script, and they could use all the functions as if they were defined right there in their script at the global level, just as they would in MATLAB.Ġ2:36 Well, we Pythonistas know that this is a bad practice, especially when the library contains tons of functions. And, as we’ll learn soon, it does a lot of work for us behind the scenes. pyplot is the high-level interface we can use to perform common actions on our plot. These functions all exist inside of a submodule of matplotlib called pyplot.Ġ1:37 pyplot contains a collection of command style functions that mimic the behavior of MATLAB. The Python concept of importing is not heavily used in MATLAB, meaning that most of MATLAB’s functions are readily available to the user at the top level.Ġ1:22 These functions can be called on their own, instead of on some object or a module alias. But now Matplotlib is a full-fledged community effort developed and maintained by a host of talented individuals.Ġ1:03 One area where Matplotlib draws inspiration from MATLAB is in its global import style. He wanted to emulate MATLAB’s plotting commands, but within Python, effectively combining the power of both Python and MATLAB.Ġ0:51 Unfortunately, John passed away in 2012. Hunter in the early 2000s.Ġ0:35 His original inspiration for the project came from the popular MATLAB software. Matplotlib was originally developed by a neurobiologist named John D. To help understand that, we first need to look at the history of Matplotlib. This includes pyplot and PyLab, object hierarchy, and stateful versus stateless approaches.Ġ0:16 This video will cover pyplot and PyLab.

00:00 Before we can start coding our graphics, we need to talk about some of the theory behind Matplotlib.
