SPEAKER 1: Hello, world.
This is the CS50X x educator workshop.
Can everyone hear me OK?
Amazing.
So this is our last day together, at least for the workshop in particular.
We'll be joined, of course with CSF CS50s own Brian
Yew on CS50s introduction to Artificial Intelligence with Python.
This, of course, is our newest class, all thanks to Brian.
And it is another follow on class that students
can take after completing a class like CS50x itself.
Before we dive in, would anyone like to say a friendly hello on camera?
And feel free, as always, to chime in on the chat
by telling folks where in the world you are.
Amad, can we start with you?
AMAD: As usual, I'd like to say hello to everyone at the end of the week,
wishing them a great weekend.
And a special thank you for this great workshop, Dave, Brian, Margaret,
Kareem, everyone who was working in CS50.
I do rarely get inspired by anyone, but I am greatly inspired by you guys.
Thank you very much.
And thank you for everyone who joined.
Their comments is very valuable to me.
I saved the chat and I learned a lot from it.
So thank you.
Enjoy your workshop.
I'm looking forward to working with all of you.
SPEAKER 1: Wonderful, thank you for the kind words, and for the whole group
as well.
Andreas, would you like to say hello as well?
ANDREAS: Hello, [INAUDIBLE] professor [INAUDIBLE]..
And those in the workshop goals also [INAUDIBLE] Russia.
And I'm very glad that I was here.
So thank you.
SPEAKER 1: Very welcome.
Welcome, again.
[INAUDIBLE]?
SPEAKER 2: Thank you very much.
[INAUDIBLE] first let me congratulate you on this model
that you have provided for the teachers and especially for its content.
I can see they're very valuable as I have said before in previous lecture.
I also really appreciate the lecture, starting with you, Professor David.
And further with Professor Margaret, Brian, Kareem, Colton,
sorry if I've forgotten anyone.
[INAUDIBLE] that you practice and that you offer during this workshop I
see as very valuable to adapt, as Amad said in prior, to our teaching work.
I had the opportunity, as I told you, to complete the technology
courses at your university previously.
And I tried to figure out how some of these models work.
Finally, I would like to express my sincere appreciation
for the way the lectures are organized and for interactive communication
during these lecture.
Especially question and answer with professors.
And thank you for being part of this course, David.
SPEAKER 1: Oh, well thank you as well for being part of the whole experience
this past week and beyond.
Glad to have you back.
Abashek?
Would you like to say hi to the group?
ABASHEK: It was amazing event time.
I dearly loved each session.
And thanks for hosting in due time, so it's like 9:30 now in India.
And many times I used to do some other work in the night,
so I still try to join in the early mornings, 7:30 AM in India.
So this was really good, and all of you were amazing.
I just tried CS50x [INAUDIBLE] introduction
to computer programming background.
By now I want to try all that also.
Especially today's session, I'm really waiting.
And it was amazing.
I'm missing that this is not a physical workshop.
But nevertheless, the virtual workshop was amazing.
And thanks a lot, even [INAUDIBLE],, you were amazing.
[INAUDIBLE]
Thanks a lot, David.
Hope to see you again in such events online now
that the world has become very small because of COVID.
Thank you.
SPEAKER 1: You're very welcome.
Thank you.
Angela, would you like to say hello?
ANGELA: I think--
Please excuse my kitchen, OK?
I think it's really wonderful to have gone through all of these
and have a conceptual understanding of what each course offered.
I originally thought one thing and then I went back and forth,
because I've really gained an understanding of what all of that
means.
And you're going to change my life and many of my students
lives because of my understanding.
And so thank you, because this is going to be super helpful.
And we're all excited to be able to participate in the before classes
as well as the after CS50x classes.
And that is what has happened.
So thank you very much.
SPEAKER 1: Well, thank you, It's great to see you
again and do continue to stay in touch, however we can be helpful.
Fareed, over to you?
FAREED: Hi, David.
I just want to say thank you to you, Brian, oh, AJ, and everybody
in the back end that was really, really.
Because we just see those two weeks, but we
don't know how many months went into this.
So we appreciate it and we definitely want to continue on this.
SPEAKER 1: Thank you as well.
And indeed, behind the scenes is a whole team.
Ian and Tara and Andrew and Rongshin and Arturo.
And even more of CS50s team have been involved behind the scenes.
Ramon as well, you might recall hearing from over email before this all began.
Sylvana, would you like to say hello to the group?
SYLVANA: Yes, Sylvana from Brazil.
Hello Brian, hello David, hello all colleagues.
I want to share with you my enthusiasm about this workshop.
And first of all, I would like thank you for these workshop and opportunity.
This pandemic brings a lot of trouble and pain.
But at the same time, bring us some opportunities
like that that wouldn't be possible if it was a [INAUDIBLE]..
And I work with quality management, and daily I see a lot of opportunities
to use technology to improve the quality.
And I think it will free people from repetitive work
to work with more challenging jobs.
But there is a risk.
If people can't manage it, the technology.
And like any other quality professional, I hate to waste.
And you have these wonderful material that's ready and available to us.
Then I want to join my Brazilian colleagues, Ramon and Ignacio, that
is participating in this workshop, and translate the material into Portuguese
to bring it to more than 200 million people that spoke Portuguese.
And it is that.
Thank you a lot.
I'm very honored participating in this workshop.
SPEAKER 1: Oh, well so glad to have you.
And so glad it will prove helpful for you and others as well.
Ignacio, can we come to you next?
IGNACIO: I would like to thank all the [INAUDIBLE] Brian, Kareem, Andreas,
and everyone that I don't know yet.
And I want to thank [INAUDIBLE] Sylvana for make sure
that we are walking into translate the material that Ramon
chose to start months ago.
And we are enjoying in this [INAUDIBLE].
And I expect that I can use this material, from CS50, and maybe CS50
[INAUDIBLE],, CS50 AI, well, [INAUDIBLE] to my students more significant meaning
[INAUDIBLE].
Well is this.
So thank you.
It was two weeks.
Very, very nice.
And I got to join with you.
Thank you.
SPEAKER 1: Well, thank you.
And we'll be sure to pass along everyone's thanks to Colton
and Margaret and others, everyone who's been involved.
Rampora.
I was saving you and the family for last.
If you'd like to say hello.
RAMPORA: Yeah, thanks for the whole team of CS50 from my bottom of the heart.
I congratulate and it has helped us a lot.
Based on these interactions every day, so my son and my daughter
has taken up CS50.
And my son wants to talk to you for two minutes.
SPEAKER 1: Hello.
SPEAKER 3: Hi, hi, David.
SPEAKER 1: Nice to meet you.
What's your name?
SPEAKER 2: My name is [INAUDIBLE].
By seeing the CS50 course [INAUDIBLE].
SPEAKER 1: Nice, and you're all done with that one?
Are you going to take CS50x next with your dad?
RAMPORA: Yes.
SPEAKER 2: OK, yeah.
SPEAKER 1: Glad you're so enthusiastic.
RAMPORA: Yeah, thank you, thank you for the whole team.
SPEAKER 1: Yeah, well he has a wonderful teacher there,
I'm sure, to help him through all the bugs and challenges.
RAMPORA: We'll do that, we'll do that, yeah.
SPEAKER 1: Wonderful, welcome back.
We're so glad everyone's joined us one final time.
Please do keep in touch after this session and this week.
We, of course, will follow up by email and the like
to stay in touch as well as with resources and beyond.
Today we conclude the workshop with a look at CS50 AI, or CS50's introduction
to Artificial Intelligence with Python, led by CS50s own Brian Yew.
What I find is especially compelling about this particular class which
is CS50s and Brian's newest is that it offers an introduction
to artificial intelligence without all of the prerequisites that are generally
characteristic of courses in the space.
And indeed, Brian teaches along the way, most everything a student
would need to know.
So without further ado and for one final time, Brian.
BRIAN YEW: Thanks very much.
Hi everyone.
So glad to see you all here, and especially
for everyone who's been with us throughout this whole workshop
and to the new faces here as well.
Very excited today to talk to you all about CS50s introduction
to Artificial Intelligence with Python.
There were a couple of guiding ideas behind this new course.
And it is new, we just recorded all the lectures
over the course of the past several months.
And it only recently became available as OpenCourseWare and available on EdX.
I'd say that the first of the big guiding principles of the course,
as David alluded to, is that it's a course that's
designed to be accessible.
And in particular, it's designed to be mathematically accessible for people
that might not have a whole lot of formal mathematics as their background.
A lot of artificial intelligence nowadays
has a lot to do with multi variable calculus and linear algebra,
there's a lot of higher level math that's
required to do a lot of the more sophisticated work
in artificial intelligence.
And therefore, assumed background for a lot of artificial intelligence courses.
With this class, we certainly do assume some mathematical familiarity.
Familiarity with mathematics to the level of CS50
and comfortability with algebra and fractions and a little bit of geometry
is helpful.
But ultimately, we're not assuming things like calculus or linear algebra.
And as topics do come up that are a little bit more mathematical in nature,
things like formal logic or things like probability and statistics,
we introduce those topics in the class itself,
so that even students who haven't seen that kind of material
before can still find it accessible.
Another of the guiding principles of the class
is that it's designed to be very practical.
We introduce, in the lectures, a number of different algorithms and ideas.
And then through projects, students actually
write code to implement these algorithms.
And we thought that was a really important part of the class
too, to enable students not only to learn
about the theory behind artificial intelligence
and how it works, which is interesting and useful knowledge.
But also then to be able to write code, to take advantage of existing packages
and libraries that already exist out there for artificial intelligence
and for machine learning, and to actually create something of their own.
And then one of the final big ideas of the class, I would say,
is that it's designed to be very broad.
There is a lot of topics in artificial intelligence,
far more than you could go into detail on everything inside of a single class.
So while you could find classes out there
that could spend an entire semester or yearlong course just diving
into optimization problems or just diving into neural networks,
we've taken the approach in this class of doing a broader introduction
to a wider range of artificial intelligence topics,
so that you leave the class with some exposure
to a lot of different areas within AI.
And students that are interested in one or more of those areas
can then pursue those areas in a little bit more detail.
So the course has been available online.
And I would just be curious to hear if anyone has already
taken a look at any of those materials.
So I'm going to paste in, as I did before, a poll into the chat.
If you could go ahead and fill out that poll.
That's just going to ask you, have you looked at any of the materials?
That is to say, ever looked at any of the lectures
or ever taken a look at any of the projects,
even if you haven't made it through everything.
Just curious to see whether people have seen this material at all before.
And that'll just help me with some context.
Right now it looks like about, slightly more people, OK, more people
that have not seen the material at all.
Some people that certainly have.
Regardless of which of these two categories you fall into, hopefully
you'll learn something today.
If you've never seen the material before,
hopefully you'll get a sense for what the course is all about,
the types of things we talk about and why we talk about them.
And if you have seen the course, hopefully you'll
get a better sense for the structure and the organization of the class
and what we're hoping that students are getting out
of each of the various different components of this class, too.
All right, and there'll be another poll coming up later on today for you
all to answer, if you would like to.
So with that, let's go ahead and actually dive
into the material of the AI course itself.
And definitely, at any point today, if you have questions about anything
that I'm talking about, definitely feel free to either raise your virtual hand
if you'd like to ask a question.
Or if you'd like to, you can also just type a message into the chat.
I'm keeping an eye on both the raised hands as well as on the chat.
So if you do have any questions about anything,
feel free to use either of those means in order to get my attention.
Thanks to Arturo for pasting the link to the slides into the chat as well.
So if you'd like to take a look at those slides to follow along
through what you're seeing here, you're welcome to look at those slides
as well.
All the material for the course syllabus, lectures, notes,
projects and all, can be found at this URL here. cs50.harvard.edu/ai.
And with that, let's go ahead and begin with a look at introduction
to Artificial Intelligence with Python.
And we're going to start by talking about the syllabus.
So the course is divided into talking about seven major topics
within artificial intelligence.
And within each of those broader topics, we
spend some detailed time talking about some of the algorithms and the ideas
and the principles that are at the heart of modern artificial intelligence
and machine learning.
And the first of those broad topics is about search.
In other words, we're trying to answer the question,
how is it that artificial intelligence can search for solutions to problems?
Because that's often what we want artificial intelligence to do.
There is some problem that's difficult for humans to be able to solve,
and we'd like for a computer to be able to solve that problem better
than humans can solve that problem, or faster
than humans can solve that problem, or maybe some combination of both.
So what might those search problems look like?
That's sort of where we begin to set the scene.
A search problem might be something like a puzzle.
If you've ever played with these little 15
puzzles, which there used to be a CS50 problem set about this as well.
Where you have these sliding tiles, and you're
trying to line up all those tiles so that they number themselves from one
all the way up to 15.
That's a problem for which AI might want to look for a solution.
In this case, the solution is something like,
what is the right sequence of moves to take so that you end up
in this, what we might call a goal state,
where all the numbers are in the correct order.
Another problem might be something like a maze, which we spend
a lot of time looking in the AI class.
You're starting from one place in the maze
you're trying to get to the other side in the maze.
At any particular location inside of this maze,
there are particular actions that are available to you.
And this might feel a little bit abstract,
but you might translate it to the real world
by considering something like driving directions on a map.
If I'm trying to get from location one to location two on this map,
well, I have certain roads that I can follow,
I have certain turns I can make, different roads will
take me different amounts of time to travel through.
And so I might care about figuring out what
is the best way to get from one location inside
of this map to some other location on this map as well.
And so one of the big ideas in artificial intelligence
that we try to convey here from the very beginning
is that we want to think about problems a little bit more abstractly.
Rather than just thinking about the problem,
how do I find my way through a maze, we want
to realize that finding our way through the maze
is a very similar problem to navigating our way through driving directions
on a map, which is a very similar problem to solving that 15 sliding
title puzzle.
Even though they seem like very different contexts.
In each of those situations, we have some current state
of the world we're in, like where in the world we are or where in the puzzle
we are.
And we have some goal, some place we're trying to get to.
And we have sequences of actions available to us
that take us from one state to some other state.
And once we start to think about all of these kinds of problems
with a similar language, talking about goal states, where we currently are,
what actions are available to us and so forth,
we can start to come up with general purpose algorithms.
Algorithms that are useful for solving these sorts of problems,
and also a wider variety of problems that we haven't even talked about.
And hopefully showing students how they can look at a new problem
and try to figure out which algorithm might be applicable here,
and what might be useful or relevant.
So one of the first algorithms we talk about is depth-first search.
And the idea of depth-first search, if unfamiliar with it,
is in the context of solving a maze like this, for instance.
Depth-first search is going to say like, just try one path through the maze,
so you see if it works.
And if it doesn't work, if you hit a dead end,
then just go ahead and back up and try some other path.
So a fairly straightforward algorithm, that hopefully everyone
can intuitively understand, visually.
Just try paths.
And if they don't work, try something else.
But then we try to formalize it as well.
Putting things in terms of how might you actually write code
in order to do this?
What would the data structures look like if you're going to do this?
We do assume a little bit of prior programming background,
usually a year or more of programming in Python or some other programming
language.
All of the projects in this course are in Python
so that students who have a little bit of prior Python background
can apply what they know about lists and about sets
and about functions in Python to each of these individual projects.
But we have had students who didn't come in with prior Python experience,
maybe came in with programming in a different language
or some other mathematical background and ended up still
being successful in the class by taking advantage
of the resources and the sample code that we offer as part of the class.
The class does not use R. So there are a number of possible languages
in which you can do a lot of this kind of work.
R is certainly a language that's very popular for data analysis and data
science.
Python is also good for these kinds of things, too.
In terms of which to use, it comes down to a matter of personal preference.
But Python ended up being a little better for this particular class.
In part because of some of the libraries that are available
and the really broad range of tooling that's available for Python.
It allows us to be able to create graphical games for some
of the projects.
And it allows us to take advantage of a lot of the Python data analysis
and machine learning libraries that are available and quite popular as well.
Certainly, you could imagine doing a lot of this in other languages as well.
And one of the principles in the lectures
is that although I do show some Python code in the lectures,
a lot of the lectures are more conceptually oriented.
Such that you can understand the algorithm in pseudocode.
And I show a lot of pseudocode for these algorithms in the lectures themselves.
And then students could translate that code into Python.
But you could also imagine translating it into another language as well.
And so you could take a lot of the ideas from these lectures
and use it for a different course, too.
A
Question in the chat is will we use basic Python,
or will we use the NumPy library.
A combination of both.
In the earlier in projects, it's almost exclusively just Python on its own
without additional libraries necessary.
But there are cases where NumPy can be helpful,
especially for dealing with arrays of numbers or vectors of numbers,
for example.
And there are cases in later projects where we do have some of that.
Most of the time it's just an option.
That if students want to use NumPy, which
is a mathematics based Python library, for solving some of the projects,
they're certainly welcome to.
But most of the time, they don't have to.
Someone's asking about the links to the slides from yesterday.
So all of the links to all of the sides as well as the videos
are all on the notion page that was just pasted into the chat.
So if you to that URL, you'll be able to see
all of the sessions in the workshop, as well
as links to the draft of the videos, and the slides for all of the sessions
there.
So thank you for posting that in the chat.
There's also a dropbox link that was posted as well that
contains the slides from yesterday.
So in the context of talking about algorithms,
we talk about algorithms like depth-first search,
we analyze these algorithms and in a number of different ways.
We want to think about how efficient these algorithms are.
But we also want to think about when they find us a solution,
like a path to get from point A to point B, how good is that solution?
Is it the optimal solution?
In other words, is it the shortest way to get from one point to another point.
And so we talk about how this particular algorithm, while it will work,
it'll find us a way to get from point A to point B, it might not be optimal.
It might not find the shortest path to get from one point to another.
So we introduce algorithms that do.
Algorithms like breadth-first search, that rather than just try one path
until we hit a dead end, it really tries all of the different paths,
alternating between them, looking for what the shortest path might be.
And it's always going to find shorter solutions
before it finds longer solutions.
And so here then is another algorithm we introduce to.
And then we start to get a little more nuanced about our conversation as well.
Breadth-first search might be able to find the shortest path from A to B.
But how quickly does it find the shortest path from A to B?
How efficient is the algorithm at finding an optimal solution?
And so there are some nuance that we introduce to students that there
might be two things that we care about.
We might care about finding the best solution.
But we also might care about finding a solution quickly.
And those are both valuable things that we might want to balance between.
And depending on the situation, one might be preferable over the other.
If you're looking for driving directions, for example,
between one point and another point, maybe you're
willing to wait a little bit longer for the algorithm
to come up with a faster path for you to get from one place to some other place.
But maybe there are some situations where
the time that you're waiting for the algorithm
to calculate, you may as well just start following a path,
even if it's not going to be the best path.
So there are some trade-offs here as well.
And we talk about other algorithms that might
be even faster than breadth-first search at trying to efficiently figure out
how to get from one point to another.
Building our way to algorithms like A*, if you're familiar with.
I won't get into the mathematical details here.
But A* is an algorithm that can find us the shortest path from A to B.
But it can do so without having to explore as much as some of these other
algorithms need to.
So we talk about the trade off between those algorithms,
what makes some of them better, what makes some of them worse.
All in the goal of trying to solve these kinds of problems.
We then turn our attention in this part of the class
to a different type of search problem, known as adversarial search.
Where in adversarial search problems, it's not just
that you're trying to find your way to some goal,
but that you are trying to find your way to some goal and someone else
is trying to stop you.
And this comes up the most often in the case of a game, for example.
You might be familiar with artificial intelligence that
now is able to beat the world's best chess players or the world's best
go players, even more recently.
And the way that they do this is via some form of adversarial search,
where they're thinking about what can I do that's the best possible choice.
And based on what I do, what might the opponent do to try to stop me,
and how can I design an artificial intelligence that
can play games efficiently?
And so we talk about algorithms for trying
to solve these kinds of problems.
One of the most famous is Minimax, which is an algorithm.
A recursive algorithm that really considers
what are all of the possible moves that I could make, and tries to calculate
which of those moves is the best move based
on how the opponent is going to respond to each of those possible moves.
And it considers all the way until the end
of the game what's the best move going to be in this position.
And using Minimax, you can design artificial intelligence
that can play games optimally.
That will always make the best move, no matter what the situation.
Now of course there are limits on these kinds of algorithms,
especially in games that can have a lot of moves and a lot of possible options.
It can get far too crazy complicated for a computer
to be able to consider all those possibilities
in a reasonable amount of time.
So we talk about strategies the computers can
use to try to make these sorts of algorithms more efficient.
Heuristics that they can use, or particular more mathematical strategy
is like alpha beta pruning, if familiar with that idea,
which is a strategy for trying to make these algorithms more efficient
by ignoring pieces of data that really don't matter,
that we don't need to care about.
So we talk about the algorithms for how to do that and give students
the option of trying to implement it.
And ultimately, for the projects for each of these topics in the course,
we ask students to take these ideas and take these algorithms
and write some Python code to be able to put these algorithms into action.
And so associated with this first topic search,
there are two projects that we ask students to work on.
The first is called degrees.
And this has to do with degrees of separation in a movie, for example.
Where the idea is if I give you two actors or actresses,
can you figure out how I can get from one actor or actress
to another based on some sequence of movies
that different people have all starred in.
If you've heard of the seven degrees from Kevin Bacon
type of exercise that you see on the internet sometimes.
It's very much inspired by that idea of how
do you connect people together based on works
that they have collaborated together with.
And so this is an example of where a search problem might prove helpful.
We then ask students to implement an artificial intelligence
to play a game, the first of a couple of games that we'll look at in the course.
In this case, tic-tac-toe.
So students write a program to play tic-tac-toe, an artificial intelligence
that always makes the best move.
And if they do so successfully, they should never be able to beat their AI.
No matter what, they should always either tie with the AI.
Or if they're not playing optimally, they might lose to their own AI.
But we ask students to implement that algorithm as well.
So that then is the first part of the class, all about search.
A pause now for any questions about it.
Backpropagation and gradient descent do get covered a little bit later
in the class.
We don't go into all of the mathematical details about those techniques.
In particular because those techniques involve them
a little bit of a higher level of mathematics than we
assume as part of this class.
But they're relevant enough that we want to at least talk about them
and introduce them conceptually.
So we show students, in principle, what these algorithms are supposed
to do, and then give students libraries and tools
to be able to put them into practice.
But we're not going to teach students the exact algorithm
for how they would calculate the gradient
or how they would do the math backpropagation.
Certainly those things are important.
And if you wanted to implement your own neural network from scratch,
for example, those are things you would need to do.
But for the purpose of this introductory course
that was designed to be lighter, in terms
of the mathematical prerequisites, we don't go into all of those details
there.
Other questions about anything here?
Yeah, Ramon?
I see you have your hand raised.
RAMON: My question is concerning the misconceptions that people usually
have when it comes to AI.
Like watching movies, we tend to think that AI is something.
But when we actually go to learn it, it's something completely different.
And even inside the programming coacher, I'm sure lots of people
here have some experience with command line programming and also
web programming.
But I'm sure that many people, including me,
don't really understand how AI works.
So I would like you to kind of talk about the misconceptions.
BRIAN YEW: Yes, so artificial intelligence can mean a lot of things,
and people have attributed a lot of different definitions of what
artificial intelligence is all about.
I think the best definition I've seen has
to do with both thinking and acting.
And then both whether you're being rational or being humans.
You might define artificial intelligence as thinking rationally or thinking
humanly.
You might define artificial intelligence as acting rationally or acting humanly.
In each of those four different areas contain some different nuances
and different ideas within it.
That's explained very well in Artificial Intelligence, A Modern Approach,
which is one of the most popular textbooks in artificial intelligence
out there.
Not a required textbook for the class.
But students who ask me what textbook should I
be looking at for artificial intelligence, that's the one I usually
recommend for just introducing artificial intelligence.
And there's a lot of overlap between the ideas in that book
and the ideas in this course, though they're
not a they're not a complete match.
But certainly if you watch the movies, you often
get a sense of artificial intelligence that you'll often
hear called artificial general intelligence or AGI.
Where the idea is that these AIs are effectively like superhumans
that are able to just do all human things plus more
and are way more intelligent in every capacity.
In this class, we try to get a better, more formal understanding
for the algorithms that underlie some of the more sophisticated types of AI
that you might see in other places that are often combining multiple
of these ideas together.
And just to lay the foundation for those principles
on top of which you might add other things as well.
And later in the course, we start to get into things like natural language
processing, and try and look at the task of,
if an AI actually wanted to talk to people
and communicate with people in human language, what
would the challenges there be, and how might that work.
The title of the book, someone asked me to repeat it.
It's Artificial Intelligence, A Modern Approach, by Russell and Norvig.
It's a great textbook for an introduction
to artificial intelligence.
There was just a new version in the book released fairly recently,
in the last couple of months, too.
Joe, I see you have your hand raised.
JOE: Yeah.
So there were things that were just called statistics, like K
means clustering and random forest.
But all of a sudden, those algorithms or models are called AI.
So that's the part that's confusing.
To me, I don't know if AI is necessarily deep learning,
but deep learning is a good example of AI.
So will you be clarifying that part, like OK, this
can be done without any AI.
You know, some of those models you could do by hand, if you wanted.
But that's the part that really I would like some distinction
as you go through the material.
BRIAN YEW: Yeah, certainly.
So I think a lot of what is considered AI very much overlaps with what
is statistics or what is, in some cases, linear algebra,
especially when we get into the world of neural networks.
Because really, it comes down to just mathematical algorithms
that are known for being able to solve a particular type of problem.
And so I think there is a lot of overlap there.
A
Lot of what we might just think of as statistics, when taken to an applied
to a problem that maybe humans previously weren't as good at solving
or that seem like the type of thing that requires human thought and calculation,
then we could start to call that artificial intelligence.
But people are going to disagree on what the exact definition
of artificial intelligence is.
It's a sort of philosophical question that can take you
in a number of different places.
But what you'll see throughout this course in particular
is that a lot of what we think of as artificial intelligence
is really just algorithms that are based on some mathematical fundamentals,
things like logic and statistics and probability, that are then
applied to solve a more human like problems, like solving a game,
for example.
Looking for other questions.
Oh, so applications of artificial intelligence.
Are there more commercial applications?
Yes, certainly.
And we'll get to some of those in some of the later projects, too.
Games are usually a good place to start, just
because they're a relatively well-defined and simple world
in which you're operating.
And therefore, the algorithms are a little bit easier at first.
But soon, especially when we get to the machine learning side of things,
things start to get a little bit more sophisticated.
So I'll go through some now of the other topics that we talk about in the class.
The next big topic is about knowledge.
And so this part of the class is entirely about
how is it that artificial intelligence can
represent information and knowledge.
And how can AI use that knowledge to be able to draw new conclusions
and gather more knowledge in the future as well.
So one of the simplest ways to represent knowledge is using propositional logic.
We don't assume that students have seen propositional logic before,
necessarily.
Though they've probably come across concepts
like not, and and, and or, at least in the context of programming.
But we introduce some more logical language for how these operators work.
And if you're familiar with logic, we introduce students to truth tables.
It can be used in order to determine how to evaluate
some sort of logical expression.
Determine if something is true or false.
And this, we relate to AI in the context of,
we want AI to be able to answer questions about is something true?
We want AI to be able to have some pieces of knowledge
and to be able to infer new pieces of information
from that existing knowledge.
And so we talk about rules for logical inference,
for being able to take existing pieces of information,
and then draw new conclusions from those existing pieces of information.
And so here is a simple example of a logical rule.
All this logical rule is saying is that on the first line we have A implies B,
or alpha implies beta.
Meaning that if the thing on the left is true, then the thing on the right
is true.
Therefore, if we know that the thing on the left is true,
alpha, then we can conclude that the thing on the right is true, beta.
And that's a relatively simple logical inference rule.
And there are many simple logical inference rules.
But by combining them together and using algorithms
to be able to use existing knowledge to draw new inferences,
you can begin to draw more complex conclusions.
Now propositional logic isn't the only way to represent information.
There are other ways as well.
We introduce students to a little bit of first order logic, which
is a slightly more sophisticated form of logic that
allows us to represent different pieces of information, as well.
But then we turn our attention to the projects.
And these projects, for now, are applications of the representation
of knowledge and information.
And so the first project we ask students to ride a solution form
is called Knights.
And this is really a writing AI to solve these sorts of logic puzzles.
You may be familiar with these logic puzzles
where you have some people that always tell the truth and some people that
are always lying.
And based on what they say, you have to draw some conclusions from it.
We asked students to, even if they couldn't
be able to solve these kinds of puzzles on their own,
to be able to write an AI that is able to solve these puzzles by logically
deducing what the answers must be.
And this is really more of a warm up problem
for the main problem of this project, which is another game,
and that game is Minesweeper.
So Minesweeper, if unfamiliar, is a game where
you're trying to identify where mines are located on a grid.
And you do so by clicking on cells that tell you how many mines surround
that particular square.
And so using that information that you're given,
you have to draw logical conclusions about where the mines might be
and what should happen next.
And so this is an example of using and representing
knowledge to be able to draw new conclusions in the future.
Good books or resources on propositional and predicate logic.
There are a couple.
I'm forgetting the titles offhand.
I know that the AI book that I suggested does
talk a fair bit about propositional logic
and maybe predicate logic as well.
But this is an area where you might be able to find books that aren't even AI
specific, that are just more generally about propositional or predicate logic
too.
So that then is the part of the class where we're talking about knowledge.
Representing information, things that our artificial intelligence can know.
But oftentimes when dealing with information in the world,
we're not dealing with information that artificial intelligence
knows for certain.
We're dealing with uncertainty.
Things that artificial intelligence might be uncertain about,
and how does AI deal with uncertainty and uncertain events
to be able to draw new conclusions.
Prolog is question that was asked about--
Prolog I don't have a lot of experience with Prolog.
I know that it's a logic programming language that's
very useful, in particular, for the kinds of propositional and predicate
logic topics that we were just talking about in the last section.
So for being able to draw inferences based on pieces of knowledge,
Prolog and Datalog, which is closely related,
are quite good for that kind of thing.
But they're probably less applicable for when we get further
into some of the other topics in AI, where we really
want a fuller procedural programming language, something like Python,
where Prolog might be a little bit limited.
But for certain types of problems and certain types of questions,
logic programming languages like Prolog can actually be quite helpful.
And I think they're a good way of showing propositional logic
and predicate logic, too.
All right so on the topic of uncertainty.
This is the next big theme and topic within the course.
We first start by introducing students to probability,
and the fundamentals of probability.
We don't assume a whole lot of prior familiarity
with probability or statistics.
So we're introducing it from the beginning.
Talking about what a probability means.
Just some value from 0 to 1, in this case
representing how likely it is that when I roll a die, I get the number
2, for example.
So we could draw these examples of what probability's all about.
And usually in the context of what we want
our AI to do, and in the context of probability more generally,
we don't just care about what is the probability of some event happening
in the void.
We care about something called conditional probability.
We care about, what is the probability of this thing happening, based
on information that we already know.
So we might care about the probability that it rains today.
But we can get a better answer by asking the question, what
is the probability that it rains today, given that we already
know that it rained yesterday.
So given that existing information, how can
we use that existing information to draw new conclusions
or to make updated estimates about what we think about the world.
And this is a large part of how a lot of different algorithms
in artificial intelligence work.
That artificial intelligence is going to have
some sort of existing knowledge base.
And then based on that existing knowledge base,
use that knowledge to be able to make estimates about the world.
Question in the chat, is there an age limit to teach AI?
Is CS50 for ages 12 and up, mainly because some of the topics
can start to be more challenging as you dig into some of the more
mathematical and statistical topics.
Certainly having a little bit of mathematical comfort
and being a little bit older can help.
In the classes that we've offered through Harvard,
I've had students as young as their first or second year of high school
take the class and be successful in it.
So that age has been appropriate for students in the past.
As for whether students younger than that
might still be able to access the materials, if they
have prior comfort with Python and feel a little more comfortable with doing
a little bit of math, even though we're introducing the mathematical topics
here, certainly OK.
But we'd leave that up to the judgment of you
as the teacher to determine that to.
Yeah, certainly with high school students,
we've had several high school students who have taken the class
and have come in with a little bit of prior programming experience in Python,
but oftentimes in Java as well, and still
been able to grasp and work with the material as well.
Is there a platform to save and deploy the models like a git repository?
Certainly, if you train any model as part of the AI course
and you want to publish them on a git repository,
you're absolutely welcome to do so.
That's definitely OK.
Not strictly part of the class, not something
we expect or require of students.
But we'll talk about machine learning in a later part of this session.
All right, so we introduce students to some of the that
exist inside of probability and statistics.
So Bayes' rule is one of the most important rules in statistics,
especially as far as artificial intelligence is concerned.
And it's really a rule for helping us to be able to calculate
these sorts of probabilities.
Calculating what is the probability of this thing happening given all
of the information that I already know.
So after this, we turn our attention to some
of the data structures that are commonly used in artificial intelligence that
take advantage of this kind of knowledge and this kind of reasoning.
So these are structures like Bayesian networks, which
are some way of trying to relate together events
and trying to estimate how it is that they influence each other.
So here on the right, for example, even if you've never seen this before,
this is a Bayesian network that's trying to determine,
am I going to miss my appointment that's out of town?
And the idea is that if it's raining, well then my train might be delayed,
and if my train is delayed, that might increase the probability
that I miss my appointment.
It's a relatively simple example, just to get across the idea
that we have all of these interrelated variables.
And using those interrelated variables, we can draw conclusions.
And so this is a constructed example used in the lecture.
But in one of the projects, which I'll show you soon,
we use a model that's similar to this to solve some very real world
problems as well.
After that, we show students Markov Chains,
which are sequences of values that are determined
based on some kind of probability.
So you might try to do something like model
the weather based on a Markov Chain.
Where the idea here is that if it's sunny today,
that increases the probability that it's sunny tomorrow.
That often there are these patterns of weather.
And if it's raining today, well, that increases the likelihood
that I think it might be raining tomorrow.
That if I already knew that it was raining today, then
I think it's more likely that it's going to rain tomorrow than if it
were sunny today, for example.
And so we talk about trying to encode some
of that logic in some of those ideas and how these models can be useful.
And one of the projects touches on this as well.
Question is, what about greedy and dynamic algorithms?
Is it something that we consider as a basis for students or is it introduced?
If you're talking about dynamic programming specifically,
I don't believe any of the algorithms in this class use dynamic programming.
As for greedy approaches to algorithms, when
I get to the optimization part of the class, which is coming next,
there are some examples of algorithms that you
might consider to be greedy in nature.
But we don't assume prior familiarity with those particular terms
or this particular ideas before.
The final data structure we introduce students to in AI
is Hidden Markov Models, which are in incredibly powerful data structure
for a whole bunch of types of things.
For being able to do audio processing and
for being able to do image processing and reasoning about uncertainty
and more.
My own undergraduate research involved Hidden Markov Models quite a bit.
And Hidden Markov Models are really about trying
to understand some unknown information based on your observations.
That a robot, for example, might have sensors
that are observing things that are around it or distances
to nearby objects.
And based on that sensor data, I want to figure out
where the robot is in the world.
Or I might have audio data just recorded from a microphone,
a whole bunch of noisy wave forms.
And based on those wave forms, I want to find out,
what are the words that the person actually spoke,
and determine what those words actually are.
So these are examples of problems where Hidden Markov Models can
be an incredibly powerful tool for AI to be
able to use observed data about the world,
to be able to observe some kind of hidden state.
So that takes us to the projects related to this part of the course.
So the first of the two projects is called Pagerank.
This ask students to implement Google's page rank algorithm
for determining which pages on the internet are important
and which pages are not important.
And it becomes an interesting question, of what does it mean for a web page
to be important, and how, given the entire network of pages on the web,
could you calculate which pages are important
and which pages are not important?
And it turns out that one way that you can do so
is by using the Markov model structure, the Markov chain
structure that I showed a little bit earlier, to try
and map out how these pages relate to each other
and how those pages connect to each other.
The other one, which has a more scientific application,
for those students who are interested in sciences,
is interested in biology and other applications of these kinds of ideas,
is called heredity.
And this is asking students to do some genetic analysis using AI.
To be able to calculate what's the likelihood
that children or grandchildren of particular people
are going to have certain genetic characteristics based on things
we know or don't know about their parents, for example.
And this is a great example of a distinction between observed data
and actual information.
That you might observe whether some genetic trait expresses itself
inside of some human being.
But that's what you observe, and you might not necessarily know,
in an underlying sense, what are that person's genetics?
But you still want to be able to reason about those genetics
and connect the genetics of parents to the genetics of their children
and to do those sorts of calculations.
So what you're looking at here is a Bayesian network
for doing this kind of analysis for the genetic relationship between parents
and their children.
And we show how you can use the same tools
we were using in AI to be able to calculate
if I'm going to miss my train, for example, to now determining
whether or not the child is going to have some genetic trait,
or what the likelihood of that is going to be.
So we try to take these data structures and ideas
and apply them to a number of different contexts.
We first applied it to the context of analyzing the web
and understanding the internet.
Then we also apply it to the biological sciences, as well.
So those that are the first three components of this seven part class.
Its search problems, understanding knowledge, and then understanding
uncertainty and how to deal with uncertainty.
I'll pause now for any questions about anything so far.
All right-- Oh, Ramon.
Yeah, I see you have your hand raised.
RAMON: I'd like to ask, for students who have never had experience with AI,
how do they deal with these first three topics?
What are the struggles and what kinds of things do they get right, right away?
BRIAN YEW: So it varies a little bit by the project.
In terms of where I see students struggling the most,
some of it in the early projects is just with familiarity
with certain Python data structures.
That we assume that students will know how to use a list in Python,
use a dictionary in Python, and even use a set in Python
to be able to store and represent data.
And sometimes students who may not have programmed too much in Python
or may come from a different language don't
know how to use those data structures as well as other students do.
And so that's something we work with students on in our weekly sections,
as well as in office hours, is just on building that comfortability
with dealing with data structures in Python.
And in addition to that, I would say that in some of the later ones,
in particular with the project that I just talked about,
some of the greater struggles are with the probability in the statistics.
Because oftentimes, probability is not something
these students have seen before.
And as a result, calculating conditional probabilities
and generating probability distributions is very new.
And so it's sort of a two part process of one,
making sure that students are comfortable
with the mathematical fundamentals.
And then applying those mathematical fundamentals and writing them in code.
But we try to provide some distribution code to students
to help students along with it.
We give students example code of some implementations of these kinds of ideas
that they can look at, all in the service of trying
to help provide the necessary support so that students can then go and build out
these algorithms.
Ignacio?
IGNACIO: I see one question here that is a lot of like [INAUDIBLE]..
Can you just talk a little bit about this?
In Brazil, the students don't have [INAUDIBLE] about probability.
The high school students, we just teach about frequencies probability.
What is the probability of the number one [INAUDIBLE],, for example.
So we don't walk in a lot of conditional probability.
How do you deal with this situation in the course, and how about programming?
Is expected that these students take CS50 before, or just a little
bit knowing in Python is enough?
BRIAN YEW: Yes, so in terms of prior background that we expect,
programming and mathematical familiarity at the level that you would get
from taking CS50x is the prerequisite.
Some students get that through taking CS50x itself,
other students have had prior programming experience
in another language that can work.
As for the probability that is introduced in the class,
we don't expect that students have seen any of this notation before.
We do expect that they're familiar with algebra and variables and fractions
and those sorts of notation they might see.
But the probability specific notation, of what
is probability, what is conditional probability,
we don't assume any of that prior background.
And so we introduce that to students in the lecture itself.
And the way that we structure the class at Harvard
is that the lectures introduce the material conceptually and give students
their first look at it.
Then students attend a section led by a teaching fellow
where that teaching fellow, in this week in particular,
will spend some time going through the mathematical notation
again, reviewing it, making sure students are comfortable applying
the formulas that we show to students, in terms of how to calculate
conditional probability, for example.
And then they use that knowledge they've gotten from the sections
and from the lecture to then apply to the projects as well.
All right, so hopefully that answers that question
about the other mathematical prerequisites there.
Ramon, you still have your hand raised.
Do you have another question, or is that leftover from before?
RAMON: Yeah, I have a question.
My question is you said that some students come
to the class with some lacks of knowledge in mathematics
and also programming.
And the question I'm going to ask comes from a personal struggle
that I had in my major at the University.
Because I was struggling with calculus and also logic,
like propositional logic, and in these two subjects.
And I asked the teacher, what are the uses for these two subjects?
And they said, oh, AI.
And I would like to ask, if in the beginning of the course,
are these students expected to know a logic,
propositional logic, calculus, discrete mathematics?
Or is it approach leading the course, if not in the beginning?
BRIAN YEW: No calculus.
In terms of discrete mathematics, we would expect like algorithmic thinking
to the level of CS50.
Like, CS50 introduces the idea of, OK this is a linear algorithm,
or this is a n squared algorithm, for example.
Those are topics and ideas that do come up,
that it's helpful to have some familiarity with, just in terms
of trying to write efficient code.
As for propositional logic, we don't assume any of that prior background.
We start at the beginning with truth values,
with introducing students to logical connectives like
and, and or, and not, as well as more complex ones like logical implication
that many haven't seen before.
And we walk students through that from the beginning.
All right.
Let's go ahead and go onto the next topic.
But I can certainly take more questions as we go.
So the next big topic of AI in this class is optimization.
So the idea here is that we want AI, only
to find a good solution to a problem, but to find the best possible solution
to the problem, by exploring what possible solutions are out there.
So this is useful in projects like trying to plan something, for instance.
So here, a problem might be if you're planning a city
and there are all these houses and you're
trying to decide, where should the hospitals be?
Ideally, you want the hospitals so that they're
close to where people are living.
You don't want necessarily-- if you only have two hospitals in the city,
you don't want them both in one corner of the city
where it's going to be difficult for people on the other side of the city
to get to.
So what algorithms could you use to optimize that sort of placement?
These are the kinds of questions that we answer.
And oftentimes, these problems can be solved via some form of hill climbing.
That you have a whole bunch of possible options, each of which
are varying degrees of good or optimal.
And by exploring what are your neighbors,
you can try and always go to a neighbor that
is better than your current position.
And I'm glossing over some of the finer details here,
but that's just the general idea of this algorithm.
That if I have this landscape of places that I can explore, what I want to do
is try to explore through this space in order
to find where the maximum is by always going to whichever of my neighbors
is taller than I am in order to continue to try to climb higher and higher.
Someone in the chat asked about the A* algorithm.
We introduce A* algorithm in the very first lecture about search.
It goes nicely with topics like depth-first search
and breadth-first search because it solves similar types of search problems
and uses heuristics to try to do so efficiently.
We talk about the problems that you might encounter with hill climbing.
In particular, with this particular layout,
you might get stuck at this shoulder or this sort of flat area
inside of this state space landscape, as it's called,
where you're on one of these, but neither one of your neighbors
is higher than you.
So you don't really know which direction to travel in.
And we talk about some of the algorithms that
can be used to solve this type of problem, as well.
And then, and here's where some of the algebraic familiarity comes in handy--
we talk about a type of programming called linear programming.
Linear programming is all about solving problems
by writing mathematical equations that you can solve in order
to get what the answer is going to be.
So you have some function that you're trying to make as big as possible.
You're trying to maximize it.
Or you're trying to minimize it as much as possible.
But you're trying to do so subject to constraints.
So this might have business implications, if for example, you're
trying to maximize your profits, but you're
constrained by how many employees you have
or you're constrained by how much area you have
or you're constrained by what resources you have, for example.
So there are a lot of artificial intelligence problems
that can be solved just by writing some equations.
And then, it would be pretty tedious for us, the humans,
to solve these equations.
But you can give it to a computer that has algorithms for solving
these kinds of equations as well.
And we introduce students to some libraries
that are good at working with linear programs
so that they can give the computer some equations
and the computer will solve the optimization problem for them.
And then finally, in this part of the course,
we talk about a particular type of problem called constraint satisfaction
problems.
And so these are problems where you're trying
to figure out what the answer is, subject to certain constraints
on what your answer can be.
So if you've ever solved a sudoku puzzle, it's very much like that idea
where you're trying to place numbers in the grid, but there are constraints.
Like you can't have the same number in the same row or in the same column.
And in a real world setting, this might come up
for a college or university in the context of something
like exam scheduling.
Where you have all of these students who are all enrolled in different classes.
You need to schedule final exams for everyone,
but you don't want any one student to have
to be in two exams at the same time because that
might cause scheduling problems.
So you need to figure out when all the exams should be, in such a way
that all of these constraints are satisfied.
And so this kind of exam scheduling where
students are taking these classes, they need
to figure out what exam slot they should go into, is one example of this.
And we talk through how you might solve that.
And then we extend that to the project students work
on in this part of the class, which is writing a crossword puzzle generator.
So it's just going to generate crossword puzzles
to figure out what words need to go where, pursuant to certain constraints.
The constraints in this case being that the word going across
and the word going vertically, if they intersect with each other,
they need to have a matching letter there, for example.
So we talk about those constraints and how to solve them.
And so that first part of the class really
introduces students to a wide variety of topics in artificial intelligence
more broadly.
In the latter part of the class, the last three topics that we talk about,
those all start to get into machine learning itself.
And so machine learning, you can think of as in some ways
a subset of artificial intelligence.
Artificial intelligence, more generally, is
about computers that are able to do things
that are considered to be rational or human-like or intelligent in some way.
Machine learning is a way of doing that that involves
having the computer teach itself how to perform a task based
on access to some data, usually.
That the computer has access to some information
or has access to some experiences.
And using those experiences, the computer
teaches itself how to perform a task without being given
explicit instructions for how to do so.
So the next part of the class explores these sorts of ideas.
Explorers learning, and how it is the computers learn information.
And so we start with some of the simpler algorithms for doing so.
One of the simplest algorithms for a problem of classification,
and classification is a problem where you're just
trying to take something and put it into one category or another,
is just called Nearest-Neighbor Classification.
And in Nearest-Neighbor Classification you
classify something, like in this case, classifying a point as red or blue,
by determining what other points it's close to.
And if this white point is close to a whole bunch of red points,
then we might conclude that that point should be red.
And so we talk about other learning algorithms
that computers can use to solve these kinds of classification problems
where the computer is trying to put something into one or more categories.
And this comes up all of the time in real world applications.
Notably, one thing we talk about is something like email spam detection.
How does your email filter know whether your email is spam
or not, to determine what to put into your spam filter?
Well, what it does is it uses access to large amounts of data.
It knows what emails are spam and have been spam in the past.
It knows what your good emails have been.
And so by taking advantage of that data, the computer
can then classify a new email as either a spam email or not spam email,
for example.
And so that's just one instance of how a computer might try to classify
something into one category or another.
But it comes up all the time across machine learning.
This more general problem of, can you put something
into one category or another.
When dealing with more numerical data, especially
if you're familiar with statistics, you might
be familiar with regression, where we're trying
to predict some sort of trend line for what this data looks like
and along where this data falls.
And we're trying to draw some line that tries
to be as close as possible to all of these data points.
And so we talk about strategies that you might do that.
And regression is another popular topic in machine learning,
for trying to figure out efficient ways of calculating that line
and how to make it as accurate as possible.
But we do have to be a little bit careful.
In the world of machine learning, we want
to be careful not to be too accurate.
Which seems maybe counter intuitive at first.
Like, don't you want to always be as accurate as possible?
But if I were going to draw some line or curve that maximized accuracy
according to these points here, I might draw a line like this.
That's just sort of jagged, and is what we might call over
fitting on the existing data.
It's true that it's very accurate.
It's connecting all of the data points that I have here.
But it's not going to generalize very well.
It's not going to do a very good job of generally predicting
what the overall shape or what the overall trend of this data
is, because data always has some noise to it.
But it's not that there's actually this trend where things are going up
and down and up and down over and over.
There may just be some natural noise.
And yes, exactly as the chat is pointing out.
Now this model is not going to be very good for predicting things.
And so it's not enough just to say, let's
make our model as accurate as possible based on the data that we have.
We want to make our data, our model, as accurate
as possible while still letting it generalize to new data
that we've never seen before.
And so we introduce students to this idea of over fitting on data
and how to think about that, too.
These are just some of the types of machine learning.
There are other categories of machine learning, we talk about too.
One example of that is reinforcement learning.
So this is a computer that is learning through experiences.
It learns by trying something, and if it works,
it learns to do more of that in the future.
And if it doesn't work, it learns to do less of that in the future.
You might imagine that shopping websites like Amazon
use this to recommend products to you that it thinks you might want to buy.
It might have some recommendation algorithm
that tries to suggest something to you.
And if you buy it, then it knows that it made a good recommendation.
So it can do more of those kinds of recommendations in the future.
But if you don't, if you don't try it, or if you don't buy the product,
then the algorithm maybe learns that that wasn't such a good recommendation,
and it can learn not to do that in the future.
Yes, to answer a question.
We do talk about a couple of different loss functions.
We don't get too much into the mathematical details of it.
But certainly I think at least L2 loss, L1 loss
are loss functions that we cover when talking about this a little bit more
generally.
So with reinforcement learning, we introduce students
to yet another data structure that's named after Markov, the Markov Decision
Process, which is a data structure where basically you
have a bunch of different options.
And no matter what option you take, you're given some sort of reward
based on that option.
Maybe that reward is positive if something good
happened, like the person bought the product you recommended.
Or maybe it's negative, if the person didn't buy the product you recommended.
And based on those rewards, you can begin
to learn something about what the right actions or what the right choices are.
And then a final type of machine learning we talk about
is unsupervised learning.
And so this was brought up in a question a little bit earlier.
But one of the popular algorithms in unsupervised learning
are the more general category of clustering algorithms.
I have a whole bunch of data, and I want to bunch them up
into different clusters.
So I've collected a whole bunch of samples of DNA, for example.
I want to break them down into clusters of related DNA strands.
Or I've collected a whole bunch of data from people, and I want to group people
into different categories.
There are a whole bunch of clustering algorithms.
We introduce students to k means clustering,
if you're familiar with that, as one of the algorithms that can be
used in order to cluster data together.
And there's a lot of mathematical detail that
goes into a lot of these algorithms.
But we don't expect that students are able to write
all of those mathematical details because we assume a little bit less
prior mathematical background.
But we do introduce students to tools that they
can use that implement some of these algorithms for them.
So something like Scikit-learn is a popular Python package
for doing machine learning.
In fact, one of our former teaching fellows for the artificial intelligence
class now works with Scikit-learn and works
on developing some of those software tools there.
And so this helps to do some of the data processing and data analysis
and creating some of the machine learning
models that are introduced in this course
without students having to write all of the mathematics themselves.
And so we use this, in particular, in one of our projects
which is about shopping.
It's about, can you predict based on data,
whether or not the user is actually going to make a purchase
or not make a purchase.
And so this has a lot of business implications.
A lot of shopping businesses are going to do something along these lines
in order to get more data and to make these kinds of predictions.
And so we give the students a sample of some real world data
about when users have bought products and when they haven't and asked
them to use Scikit-learn to be able to create a machine learning model to try
to predict this kind of thing as well.
We also introduce students to get another game.
Nim is a game where you're trying to remove objects from a collection,
and you're trying not to be the last one to remove an object.
And this is a game where instead of having students implement or tell
the computer exactly what to do and give it the Minimax algorithm
to solve it completely, we just let the computer teach itself how to play Nim.
Let it play 10,000 games of Nim against itself, and every time it plays a game,
when it wins, it learns what to do next time, and every time it loses,
it learns what not to do next time.
And this is an example of how reinforcement learning can
be used in order to be able to perform a task,
even if it didn't know how to do so before.
And there are great examples of reinforcement
learning across the board.
It's especially popular in robotics.
Teaching a robot how to do something, like walk,
it's an incredibly complicated task.
So instead, people usually will tell the robot to teach itself how to walk.
Like just tell it to try things, and if it's walking more successfully,
have it do more of that in the future, and if not, do
less of that in the future.
There is a great YouTube video.
I don't have it up now, but if someone can
find it and paste it in the chat, of a robot that learns to flip pancakes.
The robot starts out not knowing how to flip pancakes.
But over time, by trying it out again and again, and you
can see some of its early failures, which are not very
good attempts at flipping pancakes--
thank you, Arturo for pasting that link.
Eventually, the robot learns how to flip a pancake very successfully.
And so that too is an example of using motion capture
and reinforcement learning to try to solve some of these problems too.
A pause now if there are any questions about anything.
Joe, I see your hand is raised.
JOE: Yes, I want to clarify my understand, distinction.
So machine learning and deep learning, versus the previous section.
So can we assume that all the other models outside of machine learning
will always have explicit rules, the full algorithm will be written,
you don't need training data, or you don't need a lot of data to train it.
It does not improve on its own.
Is that safe to assume?
BRIAN YEW: That's often the case.
I want to stray away from saying that's exactly
the way it's going to be all the time.
But generally, machine learning is characterized
by algorithms that have access to data.
And then using that data, the algorithm can get better.
So with more data, you can end up with a more accurate algorithm.
And that contrasts with something like the Minimax algorithm
we saw or some of the search algorithms we saw, where all you need
is the problem you're trying to solve, and we try and figure
out how to solve the problem using that.
As opposed to having access to existing banks of data
that we use to learn from.
So usually machine learning is going to be characterized
by having access to information and prior data
and drawing conclusions based on that data that's available.
As for deep learning, specifically, deep learning
is a subset of machine learning.
It's a particular kind of machine learning.
And when we talk about neural networks, which is the next topic,
I'll talk about that briefly as well.
So that leads in quite nicely to the next topic.
Classification and clustering.
Oh, data pre-processing.
Yeah, for some of the projects, students do have to take some data
and then pre process that and get it into a format
that the machine learning models will understand, that's true.
In this topic, machine learning, it will also
be true in the neural networks part of the course as well.
Not extensive, the data is mostly pretty clean.
But there is some work that still needs to be done.
So this leads into the next part of what the artificial intelligence class talks
about, which is about neural networks.
Neural networks are a tool that are used in machine learning,
and they have become incredibly powerful.
They're used for so many different problems.
Now for clustering, they're used for classification,
they're used for reinforcement learning.
So there are many, many applications of neural networks
to a wide variety of different problems, and so we
spend some time talking about them.
Now I should note that really understanding
exactly how the neural network works requires some higher level math,
requires some linear algebra.
And so we don't go into all that mathematical sophistication,
just in this introductory course.
If this is something that students are interested in, though,
you can find online many good online resources and courses
for them going deeper into deep learning itself and looking at neural networks
in particular.
You could spend entire courses that just talk about neural networks
and deep learning.
There's a great one from MIT, there is one on Coursera
as well, I'm forgetting their exact names.
But some great classes that dive much deeper
than we do on this particular topic.
We introduced this in just a single week at a more higher level,
so that students can see it and still build neural networks of their own,
but without going into nearly the same mathematical details.
And the principle for neural networks is really inspired by biology.
That in human brains, we have neurons that are connected with each other,
and those neurons pass information from one neuron to another
so that one neuron might be activated and then
pass that activation onto some other neuron, for example.
And what neural networks are, or artificial neural networks,
in this case, are the same idea but applied in computers.
Rather than use a literal neuron, we're going
to use an artificial neuron, which we usually
represent which just a circular node.
And those artificial neurons are connected to each other.
Thank you [INAUDIBLE] for pasting the link to some of the deep learning
Coursera courses in the chat as well.
So that's definitely a resource to potentially take a look at.
So in the context now of what these neural networks are and how they work,
each of these nodes, each of these units inside of the neural network,
is usually calculating some function based on the inputs, based
on the values that are coming into it.
And there are a number of different functions
that I might use, for example.
Some will use a steep thresholds.
So we talk about what it means for there to be this hard threshold function.
Some will usually use a softer threshold function
that has a bit of a nicer curve to it for example.
But by combining these units together, you
can start to create neural networks that accept some data as input,
and are able to predict some data as output.
And effectively, what the neural network does,
is the neural network is a big function.
The function is just taking numbers as input, generating numbers as output.
And the question is, what does that function do?
How does the function work to translate the input to the output?
And the neural networks are designed in such a way that
using an algorithm, known as the backpropagation algorithm,
we can train the algorithm, we can train the individual units
inside this neural network to learn what the right function is.
So even if you don't know what the function is to go from the inputs
to the outputs, you can train a neural network
to be able to figure that out for itself.
And people have been able to use this technique
to do incredibly powerful things, especially when
it comes to multi-layer neural networks that aren't just input and output.
But inputs that go to some intermediary layer, and maybe even more layers
after that.
And then to some kind of output.
And these multilayered networks are able to solve some amazing problems,
and I'll show you an example of that in just a moment.
And there are several different types of neural networks,
different architectures, as they're called, for neural networks,
for solving different sorts of problems.
One of the common problems we want to use neural networks to solve them
is something like computer vision.
Being able to, for example recognize handwriting.
If I handwrite the number two or I handwrite the number eight,
can you look at that handwritten information and figure out is it a two
or is that an eight?
If you were to write this from scratch, it would probably
be quite difficult to do.
Because everyone writes their numbers a little bit differently.
How exactly would you construct the if statements, or the loops,
for example, to be able to figure out exactly what number it is.
It would be challenging to write code manually to do this.
But our neural network can solve this problem pretty readily.
In fact, there's a particular type of neural network called
a convolutional neural network that takes the image,
tries to reduce it down to just the relevant features,
and then perform some calculations to then try to figure out
what digit is it, or try to do some kind of processing on that particular image.
And there are other types of neural networks as well.
Recurrent neural networks when dealing with longer sequences of inputs
and outputs.
This is especially useful for things like machine translation, where
you're trying to translate one language into another.
It can be quite helpful for doing that sort of thing, too.
So lots of different applications for neural networks as well.
And just for fun, I thought I'd show you perhaps one
of the coolest applications, in my opinion, of neural networks.
I'm going to show you two images.
Image one on the left, image two on the right.
And I'm going to ask you a question.
Can you predict which of these two images was computer generated?
That is to say, generated by a computer as such
that it's not a real photo of a person, but actually
it's just entirely computer generated.
And if you'd like to answer on the poll there.
I'd be curious to hear people's answers.
All right, we'll take a look at the results.
Looks like slightly more than half of people
now think-- or actually, it's alternating back and forth,
it's pretty even.
Totally OK if it's pretty even, because Joe and Tristy are correct,
both of these images are computer generated.
Neither of these is a photo of a real person.
Both of these are just generated by what's
known as a generative adversarial network,
just a neural network that has been trained
to generate photos that look photo realistic, look like real people,
but actually are not.
And yes, Andrew has pasted a link to thispersondoesnotexist,
which is an implementation of such an idea that you can go to that page
and refresh it again and again.
And every time you go to that website, you're
going to get a different photo of a person that does not exist.
And so incredibly powerful tools that neural networks--
problems that neural networks can solve and things that they can do,
which are quite interesting.
So we introduce students to how to do some of this type of work,
how to write and create a neural network in order
to solve certain types of problems.
In particular, we introduce students to TensorFlow,
which is a popular library framework for solving machine learning
sort of problems.
And we use this in particular for the project that students work on,
which is this traffic problem here, where
we ask students to think about how self-driving cars might work.
And one part of a self-driving car is going to be looking at photos
and identifying what road signs are in those photos.
Figuring out, is that a do not enter sign, is it a stop sign,
is it a speed limit, if so, what is the speed limit?
And this is a problem that AI researchers have to deal with.
There was an article a couple months ago,
if someone can find it, of someone who is able to fool the Tesla computer
vision algorithm into thinking the speed limit was some different speed limit
sign, for example.
And so this is an active area of research, where people are really
trying to figure out how do you train neural networks to be
able to look at photos of street signs and figure out
what those signs actually are.
And so we asked students, using TensorFlow, to build a neural network.
We give them a whole bunch of data of existing street signs,
and try to have them build some classifier that can take some images
and then try to predict which of those images
are which particular street signs as well.
Ramon, I see your hand is raised.
RAMON: My question is, are all of these topics fundamentals for AI?
Or are there some topics that are more advanced
and really, really specific for a certain field in AI?
And if that's the case, why did you choose these as the basic topic
topics instead of any other ones?
BRIAN YEW: Yeah, so AI encompasses a wide variety of different techniques
and strategies and approaches.
And they're not all necessarily related to each other.
Oftentimes they're inspired by similar ideas
or may use some similar principles or algorithms.
But there are a lot of different algorithms
that might be falling under the broader category of artificial intelligence.
So ultimately, there were a lot of topics
that I could have or thought about talking about in this course that
ultimately didn't make it, simply because we had to pick and choose
what was the right curriculum for just this introductory class.
In terms of the material that I chose, it was informed by two main factors.
One, in particular, was a what is going to be
the most general purpose and relevant tools for solving
a wide variety of problems?
There are a lot of AI algorithms that are
very specific to one type of problem, and I
tried to focus more on broader AI algorithms that can be
used for a lot of different problems.
For solving clustering problems in general, or for solving classification
problems in general, or for performing search algorithms in general,
for instance.
So that was the first component.
The second component was trying to identify which topics would
be most mathematically accessible.
There are some topics like neural networks that, on their own,
are not mathematically accessible, that I still thought were worth
talking about.
So the course tries to introduce those in a more
mathematically accessible way.
But there are other topics where we tried
to choose algorithms that would be most intuitive for someone who had never
seen these sorts of algorithms before.
That they could then learn more about if that was
something that was interesting to them.
In terms of the connection to biology, that's
actually one thing that we try to talk about a lot throughout the course.
And one thing you'll find is that a lot of the ways that we approach algorithms
is similar to thinking about the ways that humans might learn.
In particular, when it comes to machine learning.
That with something like reinforcement learning,
for example, it's learning through experience.
It's learning through reward.
When you do something well, you get a reward,
you learn to do that more in the future.
You get some punishment, you learn not to do that kind of thing in the future.
It's the way that some humans might learn, especially children.
And we can apply the exact same techniques
to work with computers as well.
And there are even other types of algorithms like genetic algorithms
that are used in evolution and reproduction based model
to try and grow artificial intelligence into more and more intelligent systems.
And that too, very much inspired by the world of biology.
So there's a lot of connections between biology and artificial intelligence.
Ramon, go ahead.
RAMON: Yeah, my question is, which of these topics
do you feel more excited to teach, and which of the topics
did you feel more challenged to deliver to students?
And my second question out that way, now that you
have talked about all of the topics is the mantra or the principle for AI
to do things like logically or in a humanly way,
like you said at the beginning of the session.
BRIAN YEW: Yeah, so I think it's hard to come up
with a topic in this list of topics that I wasn't excited to teach.
Because I came up with-- when I was first brainstorming for this class,
there was a very long list of topics that I could have talked about.
And I very consciously narrowed it down to just the ones
that I thought would be most interesting and exciting for students,
most relevant for them, most accessible.
And so really, all of these topics are things
that I have a lot of very personal interest in.
The last topic, which we're about to get to in a moment,
in particular, language, in college, I studied linguistics.
And so studying language and natural language processing
is a very much an interest of mine, and something
that I thought about for sure.
Ethics are something that are not in any of the lectures themselves.
But I do think AI ethics are incredibly important.
Harvard has had a longstanding program called embedded ethics
for trying to include ethical discussions in their computer science
classes.
And so certainly, if you end up teaching the material,
I'd encourage and discussion sections to be
able to talk about the sort of thing.
And I think that these are the sorts of conversations that are really good
not to have someone lecturing at you for,
but for students to be really thinking about, brainstorming ideas, even
writing about it, to be able to talk about these topics as well,
to be able to think about the implications of these decisions,
especially lately.
Things like facial recognition which computer vision is becoming good at,
are things that have come under criticism for in the United States,
in particular, but also elsewhere.
So definitely topics that are absolutely worth thinking about and considering
and discussing as well.
Is there a way--
I see Joe's question.
Is there a way to distinguish between where brute force programming stops
and where AI starts?
Oftentimes, AI will look to take brute force algorithms
and try to make improvements upon them.
So you might take a brute force algorithm like Minimax.
And Minimax, you might still consider artificial intelligence,
because it's able to do something intelligently
or rationally, for example.
So that you can solve a problem that you otherwise
would have had a more difficult time trying to solve.
But what we tried to do in order to solve more complex games,
games like chess or games like go, where it
would be totally unreasonable for a computer
to brute force its way through the entirety of the game,
is to instead try to optimize them in some way.
Use heuristics, and try to figure out what data you can eliminate.
And these sorts of techniques are really where I think the heart of AI
starts to come in.
This idea of trying to use those heuristics to predict
what is going to be relevant and not relevant,
and how to avoid having to do all of the brute force
work to be able to solve the problem.
Ramon, sorry I didn't get to all of your questions.
But what was the most challenging topic to teach?
I think the most challenging topic to lesson plan
for were the machine learning topics.
All of them, machine learning and neural networks, just because most of the way
this is usually taught involves a lot of mathematics.
And it required several revisions to get through this material in such a way
that it would be beginner friendly.
And so that was probably one of the most challenging things.
Thank you, Angela, for sharing that article about facial recognition.
Definitely thinking about uses for facial recognition,
when and where it should be used, is something
that needs to be thought about.
And there are signs that technology companies are beginning
to think about that as well, and beginning
to release decisions over the course of recent weeks over that too.
All right, I'll go ahead and talk about the last topic here too.
And so the final topic that's covered in the course is about language.
And it's all about how is it that artificial intelligence can begin
to speak and understand the language of humans, to understand our language
and how it is that we communicate.
So we start by taking a look at syntax, the structure of language,
beginning to build an understanding for how AI can take a sentence
and identify what the different components
and what the different parts of that sentence are, for example.
And then we look at other ways that AI can analyze language, as well.
N-gram models that are a model where you look at sequences of words or sequences
of characters at a time to be able to perform analysis.
And that's useful, because it's often difficult for a computer
to take an entire paragraph or an entire essay and analyze all of that at once.
But it's easier to break it down into smaller discrete chunks
and analyze those chunks individually, too.
We might want to do classification with natural language as well.
So we introduced the Naive Bayes algorithm,
which does something like assess the sentiment of a sentence.
Can you tell whether a sentiment-- whether a message is positive
or whether it's negative, for example.
And so these are the sorts of questions that you might want answered.
And you might need to do with some language analysis
to be able to answer those questions.
We talk as well about information retrieval,
like how do you identify information inside of documents.
And then later, how do you extract that information out of documents?
If you're trying to answer questions for example.
So we talk about methods that can be used for doing that, too.
And then finally, to wrap up, we introduce
a system that uses neural networks to be able to analyze language as well.
Trying to put language and take words and put them into a numerical form
that computers are going to be able to understand as well.
In terms of the projects the students work on,
they work on one project that's meant to parse sentences, identify
the various different component parts of the sentences.
And then finally, the last project is to write a question and answer system.
They write a program where you can type in a question,
like what are the types of supervised learning,
and the AI is supposed to reply with an answer.
And it does so by looking through a corpus of existing knowledge,
trying to identify what the relevant pieces of knowledge are,
trying to understand what it is the question is asking, like what
are the important words in this question,
and then trying to come up with what is the best answer that I
can give to that particular question.
Naive Bayes is the name of the algorithm for doing
this kind of sentiment analysis.
It's one possible way of doing this sort of idea
where you're looking at individual words and trying
to predict whether those words are going to mean it belongs to one category
or belong to some other category.
And so that then is what it is that we cover in this artificial intelligence
course.
So we start with search, we talk about knowledge,
we talk about uncertainty, we talk about optimization
and how to try and find the best solutions to problems.
Then we turn to machine learning, trying to categorize data,
using neural networks to try to solve problems.
And then trying to write AI that can understand and deal
with natural language as well.
That wraps up our final session for the CS50x educator workshop.
So thank you all very much.
It was great to have you here and looking forward to keeping in touch
and talking more in the future.