0:00

When developing learning algorithms, very often a few simple plause can give you a,

Â better sense of what the algorithm is doing and just, sanity check that

Â everythings going okay, and the algorithms doing what it's supposed to.

Â For example, in an earlier video, I talked about how plotting the cause

Â function J of theta can help you make sure that gradient to sense is

Â converging. Often, plots of the datar, of, of the

Â learning algorithm outputs, will also give you ideals for how to improve your

Â learning algorithm. Fortunately, Autive has, very simple

Â tools to generate loss of different plots and when I use learning algorithms, I

Â find that plotting the data, plotting the learning alger, algorithm and so on, are,

Â often. Important part of how I get ideas for

Â improving the algorithms, and in this video, I'd like to show you some of these

Â octave tools for plotting and visualizing your data.

Â Here's my octave window. Let's quickly generate some data for us

Â to plot. So I'm going to set t to be = to, you

Â know? This array of numbers.

Â Here's t. Set of numbers going from, zero up to.98.

Â Let's set y1 = sine of two pi 4t. And if I want to plot the sine function,

Â it's very easy. I just type plot t, y1, and hit enter.

Â And out come this plot where the horizontal axis is the t variable and the

Â vertical axis is Y1, Which is sort of this sinusoid function that we just

Â computed. Let's set y two to be equal to.

Â The cosine of two pi four T like so, and if I plot.

Â T, Y2 What Octave will do is it will take my sinusoid plot.

Â And it will replace it with this cosine function.

Â There, now, you know, cosine of X [INAUDIBLE] say one, right?

Â No, what if I want to have, both the sine and the cosine plots on top of each

Â other? What I'm going to do is I'm going to

Â type. Plot T comma Y, one.

Â So here's my sine function. And then I'm going to use the function,

Â hose on. And what hose on does, is it causes

Â [INAUDIBLE] to now plot new figures on top of the old one.

Â And let me now plot T, Y2. I'm going to plot the cosine function in

Â a different color. So let me.

Â put A, an R in quotation marks there. And instead of replacing the current

Â figure, it'll plot the cosine function on top.

Â And the R indicates, the [INAUDIBLE] color.

Â And here are additional commands. X label time.

Â A to label the x axis or the horizontal axis.

Â And Y label values A to label the vertical axis value.

Â And, I can also. [COUGH] And I can also, label my two

Â lines with this command. Legend, sine, cosine.

Â And this puts this legend on the upper right, showing you what these two lines

Â are. And finally title Y plot puts a title at

Â the top of this figure. Lastly if you want to save this figure

Â you type print D [INAUDIBLE] DGNP. My plots, P and G, so P and G is a,

Â graphics file format, and, if you do this, this is where I should save this as

Â a file, but if I do that, then we actually change directory, to, let's see.

Â [INAUDIBLE] that. And then, I will print that out.

Â So this will take a while, depending on how your, Octave configuration is set up.

Â This may take a few seconds. But, change directory to my desktop.

Â And Octave is now taking a few seconds to save this.

Â 3:54

If I now go to my desktop, [COUGH], let's hide these windows here's my plot dot PNG

Â which octave has saved, then you know, that's the figure I have saved as a PNG

Â file. Octave can save thousands other formats

Â as well so you can type help plot if you want to see the other file formats,

Â rather than PNG that you can save figures in.

Â And lastly, if you want to get ride of a plot, the closed command.

Â causes a figure to go away, so there's a figure and if I type close, you know,

Â that figure just disappeared from my just disappeared from my desktop.

Â Octave also lets you specify a figure or a number.

Â So you type figure, one, plot T, Y1, that starts up a first figure in that plus T

Â Y1 and then if you want a second figure you specify a different figure number so

Â figure two plus T Y2, like so and now on my desktop I actually have two figures,

Â figure one and figure two, one plotting the sign function, one plotting the

Â cosign function. Here's one other neat command that I

Â often use which is the subplot commands, I'm going to use subplots 121 what this

Â does is divides, subdivides the plots. Into

Â A one by two grid, that's what the first two parameters are, and in response to,

Â access the first element, that's the what the final parameter one is, right, so

Â this, divide my figure into one by two grids and I want to, access the first

Â element right now, and so if I, take that in, this product, this figure is on the

Â left and if I, plot T Y1, it now fills up this, .

Â You know, first element and if I now do subplot one, two, two.

Â I'm going to start to access the second element and plot T, Y2.

Â Well, throw in Y2 in the right hand side or the second element.

Â And lost command you can also change the axis scale and change axis to open five

Â one minus one, one and this sets the X range and Y range for the figure on

Â the, on, on the right and [INAUDIBLE] says the horizontal range of values and

Â the figure on the right to range from 0.5 to one and the vertical axis values to

Â range from -one to one. And you know, you don't need to memorize

Â all these commands if you ever need to change the axis all you need to know is

Â that there's an axis command and you can really get the details from the usual

Â auto help command. Finally just a couple of last commands -

Â ClF Clears a figure. And, here's one more neat trick.

Â Lets set A to be equal to a five by five matrix square, say, so A is now this five

Â by five matrix. There's a neat trick that I sometimes use

Â to visualize a matrix, which is I could use image S, C.

Â Of A and what this would do is this would plot a five by five matrices so it'll

Â take my matrices I'll plot this as a five by five grid of colors where the

Â different colors correspond to the different values in the A matrix.

Â So briefly I an also do color bar let me use a more sophisticated command if we

Â just see A color bar, color Map gray this is actually running three commands at a

Â time, running every emesher FC, then running color bar, then color map gray

Â and what this does, is it sets the color po, map, it's a gray color map, and under

Â writed also puts it in this color bar and,

Â So this color bar shows what the different shades of color correspond to,

Â curan frequently, the upper left elements of, the A matrix is seventeen, and so,

Â you know, that corresponds to. Kind of a mid shade of grey, whereas in

Â contrast the second element of a, the one two element of a is 24 versus a one two

Â is 24. So that corresponds to this graph here

Â which is nearly a shade of white. And the small value say a, what is that

Â a, a four five Know is the value three over here that

Â corresponds. You can see how my color bar that

Â corresponds to much darker shade in this image.

Â So here's another example I can plot a larger you know.

Â Here's a magic fifteen that gives me a fifteen by fifteen magic square and this

Â gives me a plot of what my fifteen by fifteen magic square's values looks like.

Â And finally to wrap up this video. What you've seen me do here is use common

Â training of function cause here is how we actually do this [COUGH], if I type A

Â plus one, B equals two and C equals three.

Â And hit enter. Then this, this is actually carrying out

Â three commands at the same time or really carrying out three commands one after

Â another. And it prints out all three results.

Â And this is a lot like equals one, b equals two, C equals three.

Â Except that if I use semi colons instead of a comma, it doesn't print out

Â anything. So, this, you know?

Â This thing here we call comma chaining of commands or comma chaining of function

Â calls. And it's just another convenient way in

Â Octave to put multiple commands like [INAUDIBLE] color bar, color map.

Â To put multi commands on the same line. So, that's it.

Â You now know how to plot different figures in Octave.

Â And, in the next video. The, the next main piece I want to tell

Â you about is, how to write control statements.

Â Like if, while full statements in Octave. As well as how to define and use

Â functions.

Â