1
00:00:11,700 --> 00:00:16,920
In this lecture we are going to go over a very new and exciting environment for writing deep learning

2
00:00:16,920 --> 00:00:22,230
code in Python which is Google's core lab short for code laboratory.

3
00:00:22,230 --> 00:00:26,930
For those of you who like to use Jupiter notebook this is an even better option.

4
00:00:26,940 --> 00:00:33,480
This is basically the same as you put a notebook with the following bonuses first.

5
00:00:33,490 --> 00:00:37,520
It's hosted by Google which means you don't have to use your own computing power.

6
00:00:37,540 --> 00:00:43,330
You'll notice that when you need to download data files it happens extremely quickly because while Google's

7
00:00:43,330 --> 00:00:45,760
network is extremely fast.

8
00:00:45,760 --> 00:00:52,750
Second you get access to a GP you and even Google's new TB you which is pretty amazing a tepee you is

9
00:00:52,750 --> 00:00:55,560
not something you can buy for your personal computer.

10
00:00:55,780 --> 00:00:58,660
So it's pretty nice to be able to make use of one.

11
00:00:58,990 --> 00:01:03,670
Remember that the way pi torch code is written you don't have to worry about what kind of device you're

12
00:01:03,670 --> 00:01:04,300
using.

13
00:01:04,330 --> 00:01:06,960
Well for the most part TB you is another story.

14
00:01:07,180 --> 00:01:14,200
But generally speaking the same code will work whether you're using a CPA you or a GP you third the

15
00:01:14,200 --> 00:01:16,680
code lab notebooks are stored in your google drive.

16
00:01:16,690 --> 00:01:17,980
So it's in the cloud.

17
00:01:18,160 --> 00:01:22,210
You'll never lose it and it's very easy to share with other people.

18
00:01:22,210 --> 00:01:26,950
Fourth is that many of the libraries you need for a deep learning machine learning and data science

19
00:01:27,190 --> 00:01:28,950
are already included.

20
00:01:28,990 --> 00:01:32,860
In fact I was surprised that there were many more than I assumed there would be.

21
00:01:32,860 --> 00:01:38,660
There are even competing Deep Learning libraries already included such as piano and Pi torch.

22
00:01:38,680 --> 00:01:44,640
So for those of you who hate doing environments set up myself included this is really truly awesome.

23
00:01:49,730 --> 00:01:53,920
So in this lecture we're not going to do anything really technically complicated.

24
00:01:53,930 --> 00:01:57,850
Rather we're just going to talk about Google collab and do some short demos.

25
00:01:57,860 --> 00:02:04,100
So you know how it works and can see for yourself that it's just like writing Python anywhere else to

26
00:02:04,100 --> 00:02:04,550
start.

27
00:02:04,550 --> 00:02:10,550
I'm going to assume you already know how to create a Google Drive account if you don't have one go to

28
00:02:10,580 --> 00:02:13,100
drive dot google dot com and sign up

29
00:02:18,440 --> 00:02:23,890
once you have your google drive account and you've logged in you'll see this interface from here.

30
00:02:23,900 --> 00:02:29,930
You can hit the new menu which allows you to create all different kinds of files such as Google Docs

31
00:02:30,160 --> 00:02:32,690
a spreadsheet a presentation and so forth.

32
00:02:34,340 --> 00:02:35,710
So let's do this.

33
00:02:38,240 --> 00:02:49,480
So now what you want to do is go to the more menu and hit code laboratory.

34
00:02:49,570 --> 00:02:49,830
All right.

35
00:02:49,830 --> 00:02:52,380
So as you can see this brings up a new notebook.

36
00:02:52,530 --> 00:03:01,510
And from here you can mostly use this as you would a normal notebook.

37
00:03:01,530 --> 00:03:06,180
Now one thing that might happen to you is that you might not see cool laboratory in the menu at all.

38
00:03:06,780 --> 00:03:13,200
So as you can see I've hit the new menu and I've hit more but I don't see color in this case.

39
00:03:13,200 --> 00:03:14,790
Here's what you can do.

40
00:03:14,790 --> 00:03:19,600
You want to select connect more apps from here.

41
00:03:19,610 --> 00:03:21,050
Just search for collab.

42
00:03:21,200 --> 00:03:28,030
And the first thing that will pop up is Google's collab add this and Google Ecolab will become available

43
00:03:28,270 --> 00:03:28,920
from the menu.

44
00:03:28,930 --> 00:03:29,680
We just looked at

45
00:03:37,260 --> 00:03:41,190
so if we go there again we can see that cold app and now appears where it should

46
00:03:48,670 --> 00:03:59,930
so let's go in and rename this notebook to TAF 2.0 intro.

47
00:03:59,960 --> 00:04:01,810
So first we're gonna get right to the good stuff.

48
00:04:01,820 --> 00:04:06,310
How can we make use of a GP you or you in order to do this.

49
00:04:06,320 --> 00:04:11,150
You want to go to the runtime menu and select change runtime type

50
00:04:14,150 --> 00:04:17,170
as you can see there are two select boxes here.

51
00:04:17,300 --> 00:04:20,700
The first one lets you select which python version you want to use.

52
00:04:21,350 --> 00:04:25,190
So we'll be using Python 3 for this course.

53
00:04:25,260 --> 00:04:28,560
The second lets you select what kind of device you want to use.

54
00:04:28,590 --> 00:04:37,460
So that's either none which is the default or GP you or TB you now note that sometimes the GP you or

55
00:04:37,460 --> 00:04:40,850
TB you might not be available.

56
00:04:41,000 --> 00:04:47,360
This is because these are shared resources so your fellow peers taking this course and other machine

57
00:04:47,360 --> 00:04:52,700
learning students and researchers all around the world might be using Google whole app and we are all

58
00:04:52,700 --> 00:04:54,280
sharing these resources.

59
00:04:54,350 --> 00:05:00,420
So if our usage of these resources hits the limit of what's available then you might not have a GP you

60
00:05:00,420 --> 00:05:03,270
or you available when you need them.

61
00:05:03,620 --> 00:05:08,630
For this reason some of the code you'll see in this course may be done on my local machine as well.

62
00:05:08,720 --> 00:05:13,520
But remember Python code works the same anywhere so it does not make a difference

63
00:05:19,250 --> 00:05:19,820
next.

64
00:05:19,970 --> 00:05:25,560
You can see that there are two main types of cells that we can create in the notebook code and text.

65
00:05:25,640 --> 00:05:31,940
You can click on either of these to create a new cell of that type let's click on text since that's

66
00:05:31,940 --> 00:05:35,600
a little easier and it's not really something we are going to use very often.

67
00:05:35,600 --> 00:05:37,120
So let's just get it out of the way

68
00:05:40,480 --> 00:05:42,770
so I'm actually going to delete the very first cell

69
00:05:47,440 --> 00:05:47,730
all right.

70
00:05:47,730 --> 00:05:53,760
So as you can see when I click this it creates a new cell with what looks like a rich text editor.

71
00:05:53,760 --> 00:05:59,430
You'll notice that it's split into halves the left half is where you enter your text and the right half

72
00:05:59,430 --> 00:06:01,950
is a preview of what it will look like.

73
00:06:02,040 --> 00:06:05,170
So let's enter some text.

74
00:06:05,200 --> 00:06:19,450
This is my title now you can click the little T Big T icon which changes it into header text so you

75
00:06:19,450 --> 00:06:26,680
can see that it makes this a little bigger and bolder appropriate for a title next let's enter some

76
00:06:26,860 --> 00:06:29,180
regular text.

77
00:06:29,270 --> 00:06:34,830
This is regular text

78
00:06:38,750 --> 00:06:45,070
and note that there are also these arrow brackets so it looks like it's going to let us enter code snippets.

79
00:06:45,230 --> 00:06:48,440
So let's try that.

80
00:06:48,630 --> 00:06:54,970
And so as you can see it makes the text a mono space font which is appropriate for code.

81
00:06:55,210 --> 00:06:56,710
Now there are some other options here.

82
00:06:56,740 --> 00:07:01,010
So you can make a link you can add images you can indent.

83
00:07:01,090 --> 00:07:04,590
You can add a numbered or bullet list and so forth.

84
00:07:04,630 --> 00:07:07,150
So if you're interested play around with this.

85
00:07:07,150 --> 00:07:11,960
Otherwise we're not going to mention it again.

86
00:07:11,990 --> 00:07:13,460
Next we have the code cell.

87
00:07:13,490 --> 00:07:16,970
So let's create one of those.

88
00:07:17,110 --> 00:07:17,420
All right.

89
00:07:17,420 --> 00:07:20,860
And as mentioned we're not going to write any fancy code in this lecture.

90
00:07:20,900 --> 00:07:24,950
We just want to do something simple to make sure everything works as expected.

91
00:07:25,670 --> 00:07:28,630
So let's start by importing num pi and map plot lib

92
00:07:43,100 --> 00:07:44,120
all right beautiful.

93
00:07:44,150 --> 00:07:50,030
As I mentioned earlier these already come pre installed next let's create a new code cell and make a

94
00:07:50,030 --> 00:07:53,950
sine wave.

95
00:07:54,060 --> 00:08:00,530
So first we need to create some x values so let's make X go from zero to 10 pi with 1000 points in between

96
00:08:17,310 --> 00:08:18,660
next let's make Y.

97
00:08:18,690 --> 00:08:19,890
The sign of X

98
00:08:29,070 --> 00:08:36,410
next let's create a new cell and plot what we just created so that's just peels heat up plot x y

99
00:08:43,300 --> 00:08:43,530
now.

100
00:08:43,540 --> 00:08:48,640
Since this is a notebook there's no need to call people to you that show since the plot will just appear

101
00:08:48,640 --> 00:08:49,840
in the notebook itself.

102
00:08:52,230 --> 00:08:52,500
All right.

103
00:08:52,500 --> 00:08:53,370
Very cool.

104
00:08:53,370 --> 00:08:54,990
Works just like a regular notebook

105
00:08:58,020 --> 00:08:58,700
at this point.

106
00:08:58,710 --> 00:09:05,520
We've convinced ourselves that Google collab can do the usual things you'd expect from a group a notebook.

107
00:09:05,520 --> 00:09:10,770
Now as I mentioned earlier one thing that's very nice about COLA is that it already comes with a bunch

108
00:09:10,770 --> 00:09:13,380
of useful libraries pre installed.

109
00:09:13,380 --> 00:09:17,790
In my opinion this makes Google collab way better than Jupiter notebook.

110
00:09:17,820 --> 00:09:23,260
And if anyone ever asked me to write in a notebook environment I would choose color by default.

111
00:09:23,940 --> 00:09:26,910
I'm not a big fan of notebook but I am a big fan of collab

112
00:09:32,230 --> 00:09:38,110
so here we can see that I've written some code to try and import a bunch of libraries specifically these

113
00:09:38,110 --> 00:09:42,420
libraries are libraries that have been using my causes some more than others.

114
00:09:42,550 --> 00:09:46,120
Some are pretty rarely used so you might not expect that they would be included.

115
00:09:46,180 --> 00:09:52,720
Libraries like word cloud which we've only used once so far and yet if we look we see that everything

116
00:09:52,720 --> 00:10:02,050
I've tried to import here does not throw an error so this tells us that these libraries are indeed available.

117
00:10:02,050 --> 00:10:07,280
What's interesting to me is that some of these libraries are not machine learning related at all.

118
00:10:07,390 --> 00:10:12,760
Of course we've used them in my courses because they are generally useful as Python libraries but it's

119
00:10:12,760 --> 00:10:16,930
nice to see the folks at Google also make use of these same libraries.

120
00:10:16,930 --> 00:10:18,760
And so thought to include them.

121
00:10:19,420 --> 00:10:26,610
So here you can see the usual stuff such as psychic learn name pi PSI pi map plot lib and pandas.

122
00:10:26,620 --> 00:10:31,960
We also have torch and piano which is surprising because they are competing Deep Learning libraries

123
00:10:32,350 --> 00:10:36,520
and development for the ATO has been stopped for a while now.

124
00:10:36,680 --> 00:10:43,910
We also have seaborne word cloud beautiful soup which is for X amount CML passing requests which is

125
00:10:43,910 --> 00:10:52,160
for making a CTP cause network X which is for graph functionality CV 2 which is for open CV and gym

126
00:10:52,160 --> 00:10:54,170
which is open a gym.

127
00:10:54,170 --> 00:10:57,490
All in all very impressive and much more than I expected.

128
00:11:04,620 --> 00:11:09,410
So there's some final caveats to Colette that I want to mention first.

129
00:11:09,510 --> 00:11:12,860
The main thing you have to remember is that this is the cloud.

130
00:11:12,870 --> 00:11:14,780
So these are shared resources.

131
00:11:14,940 --> 00:11:21,060
So one way this affects you is if you leave your notebook alone for a long time it will become inactive

132
00:11:21,090 --> 00:11:26,790
and disconnect any computation that you may have run earlier won't be saved.

133
00:11:26,790 --> 00:11:33,230
So for example if you define a variable A equals five AND THEN YOU COME BACK LATER AFTER your notebook

134
00:11:33,240 --> 00:11:42,100
was disconnected and you tried to print a it'll say a is not defined so you see this notebook has disconnected.

135
00:11:42,340 --> 00:11:48,370
So let's say to reconnect and I print a it's going to say a is not defined

136
00:11:52,910 --> 00:11:55,680
another way this affects you is that you might run out of memory.

137
00:11:56,210 --> 00:12:01,520
So if that happens you might want to try running the code on your local machine instead.

138
00:12:01,640 --> 00:12:06,050
And as mentioned earlier the GP you A.P. you might be unavailable.

139
00:12:06,140 --> 00:12:12,920
So either you can run your code without the GP you or TB you or you can run the same code locally as

140
00:12:12,920 --> 00:12:19,280
always options you had previously are still available for example you can provision a GP you instance

141
00:12:19,520 --> 00:12:27,440
on a W.S. which if you choose the correct EMI or Amazon machine instance will come with the usual libraries

142
00:12:27,440 --> 00:12:28,460
pre installed also.
