We all know that Python is a major player in the application of machine learning and AI.
This often involves grabbing Keras or TensorFlow and applying it to a problem.
But what about AI research? When you're actually trying to create something that has yet to be
created, how do researchers use Python here? Today you'll meet Alex Levin, a Python developer
and research scientist at Vicarious, where they're trying to develop artificial general
intelligence for robots. This is Talk Python to Me, episode 124, recorded May 31st, 2017.
Welcome to Talk Python to Me, a weekly podcast on Python, the language, the libraries, the
ecosystem, and the personalities. This is your host, Michael Kennedy. Follow me on Twitter,
where I'm @mkennedy. Keep up with the show and listen to past episodes at talkpython.fm
and follow the show on Twitter via at Talk Python. This episode is brought to you by Linode and
Talk Python Training. Be sure to check out what the offers are for both of these segments.
It really helps support the show. Alex, welcome to Talk Python.
Hi, thanks for having me.
Yeah, I'm pretty excited to talk about AI, researching AI, and all the stuff that you guys
are up to. It's something we haven't really touched that much on on the show, and it's
both interesting at a low-level, technical level, but also at a philosophical level, almost. So
looking forward to talking to you about it.
Yeah, but before we get into the details, let's start with your story. How did you get into programming
in Python?
Well, my background is a bit untraditional for what I do. I actually studied mechanical
and aerospace engineering at school, and I was determined to make a career as a spacecraft
engineer. And even some of the Mechie assignments where we used MATLAB, I hated those. But that
eventually led me to Carnegie Mellon to study space robotics.
Oh, nice.
And the atmosphere there is incredible. It's hard not to get caught up in software and AI. And
that was really my first exposure to AI.
That's cool. When I think of universities that are cool and amazing in programming and robotics
and things like that, Carnegie Mellon is right up there. Maybe Stanford, MIT, Carnegie Mellon. Those
are the top three, at least in my mind.
Yeah, absolutely. And I was fortunate enough to work with this incredible roboticist, Red
Whitaker, who was one of the, I guess, founders of the DARPA Grand Challenge of autonomous vehicles.
Oh, I was going to ask you about the DARPA Grand Challenge. Tell people about what that is. That
is such an amazing thing.
Yeah, so that started back in 2003 or 2004. And it's just a challenge to create an autonomous vehicle that drives across the desert down in Mexico. And the first year was, you ask most people, a complete failure, but it really kicked off all this research. And then the next year, it was won by, I believe, Sebastian Thrun and his team from Stanford.
Yeah, I think so.
Now it's just almost a piece of cake for these autonomous vehicles to complete the course.
Didn't the Stanford team eventually more or less move over to Google for their Google car stuff? Do I have that put together right?
Yeah, I believe a lot of them went over there. And Sebastian Thrun, I think he is very involved in the Udacity effort. They have a self-driving cohort.
Okay. Yeah, yeah. That's really cool. So when you talk about the car driving through the desert, it's not like it just drove a little ways. There's basically a dirt path through the open plains as well up into the mountains for like 100 miles, right?
Oh, yeah. You can check out some of the videos from these races. And these are like very intense off-road vehicles. It's through the desert in Mexico, I think on the Baja Strip. And I want to say it's like hundreds of miles.
Yeah, yeah, that's really cool. So yeah, there's a great Nova on this called the Great Robot Race. I'll be sure to include it in the show notes.
Oh, cool.
Yeah, it's really, really neat. But it's super inspiring. And this is not the first year, but the second year that they did the documentary. So it's not where they all failed. And they had different devices, different machines. People had robotic motorcycles. So people had huge trucks. And it seems like the SUVs were the real winners, though.
Yeah. And it's also worth checking out the DARPA challenge for autonomous human robots. There are some pretty funny fail videos up there on YouTube.
Okay, so I derailed your story, but I definitely wanted to just talk about that because that's like that was the world that you were in at Carnegie Mellon, right? And you're like, well, okay, this requires programming, right?
Yeah, yeah. So I was studying mechanical engineering and doing things like CAD and FEA analysis and all that. And my last semester there, I ended up taking one software, well, it was a software slash AI course. And it was all in MATLAB, of course.
And that really just got me hooked. I loved it. And I figured after graduation, I would just figure out a way to just pivot my career. And I wanted to do AI and software and AI research specifically.
And then, well, Python seemed to be a natural fit. And I started teaching myself Python. And then, at the same time, dove into any AI textbook and paper I could get my hands on. And then, as soon as I could, started implementing some of these algorithms and models in Python.
And some of the motivation for that came from things like Kaggle competitions and such. Eventually, I felt comfortable enough as a programmer and AI researcher to seek a position with a few different companies. And that led me to Numenta. And I worked there for a few years.
Cool. What kind of stuff did you do there?
So, Numenta is interesting. They run the full gambit from theoretical neuroscience all the way into machine learning models that are implemented for production code.
So, it was an incredible learning environment, both, I mean, from software engineering perspective and about machine learning algorithms.
But I've since moved over to Vicarious, and I've been here for about eight months now.
Okay, nice. So, what kind of work do you do now?
At Vicarious, we're working to build general artificial intelligence. So, that's AGI. Any problem a human can do, we want our AI to do. And in the past, we've pointed to Rosie, the robot from the Jetsons. But I can say that we're not building exactly Rosie, per se.
More like R2-D2?
Oh, sure.
No, okay. That sounds really interesting. And, you know, when you talk about AI, there's usually some kind of split around specialized AI or general AI, right?
Like, a specialized AI might be Siri or a self-driving car or something, like, or the thing that solves Go. It's, like, incredibly good at driving the car, but there's no way that it could tell you, you know, what's the weather.
Or, like, something that's unrelated to what has been taught, right?
Exactly.
Then you've got the more general one that you're working on.
Yeah, yeah.
There's been a lot of press lately about deep learning models and frameworks, and they've been incredibly successful and useful for some of these narrow AI problems.
A lot of times in research development of these models and algorithms, we'll use video game environments, specifically the Atari environments.
Just kind of good test beds for the approaches.
And you take, for example, a breakout or a space invaders environment, and deep learning can blow away any human player.
It's solved.
But you add some minor tweaks to the game, like change the pixel values ever so slightly or just move some blocks around.
And things that are just imperceptible to a human, they pick that up easily.
The same deep learning model fails.
So that is kind of exemplifying the narrow component of those models.
Yeah, that's pretty interesting.
So one of the challenges with neural networks and deep learning, is that basically like taking multiple neural networks and sort of treating them as a group of things that then answer questions?
Or is there more to it than that?
In a way.
Let me dial back real quick.
Yeah, okay.
Artificial neural networks are a model that dates back to...
Yeah, at least the 90s for sure.
Yeah.
And even earlier than that, I feel like I'm offending some people out there by saying...
I did that in small talk in 1974.
What are you talking about?
Exactly.
But nowadays, in the past five years and so, we've seen that we can stack layers and layers and layers of these neural networks and make them very deep.
That's where the name deep comes from because we have the computation power to do so.
So these deep neural networks are essentially function approximators.
And you can feed them a ton of data.
It could be videos from your self-driving car.
It could be text in English and French if you want to do machine translation.
And these deep function approximators are able to learn from all that data how to take your input as, for example, English and give you the output in French.
Right.
Yeah, that's really amazing.
I feel like AI and machine learning was one of those things like nuclear fusion.
It was always 30 years out no matter when you ask somebody.
It's like in the 90s, it was like, oh, yeah, we're going to have AI.
And here, we're working on this in Lisp.
And it doesn't really work.
And then 10 years later, it's like we're still doing the same basic thing.
It's not really making any progress.
But I feel like kind of like you said, like the last five years, especially the last three, four years, it's just, wait a minute.
This is actually a thing now.
This is like really today there's reasonable uses of AI in tons of ways.
I mean, we have like Star Trek coming to life with Microsoft Skype and PowerPoint, right, where it like in real time translates to other languages as you speak, right?
And just things like that.
I mean, amazing.
Yeah, there's some really powerful uses already deployed in applications.
But it's kind of funny.
The field of research for AI and specifically for general AI is almost always like the mountain climbing dilemma where you think, oh, the peak is just over the next pass.
And then you get over the next pass.
And it's like, oh, it's the next pass.
And then the next pass.
And the next pass.
Everybody told me about this mountain range on the other side of this one, right?
Yeah, exactly.
So we do have some pretty powerful AI nowadays.
But we keep pushing the limits and pushing the limits and defining this path to AGI as we go.
Yeah, yeah.
So one sequence maybe is you talked about we had the neural networks.
They could kind of do a thing.
We had the deep learning neural networks that are really good at stuff.
But you make minor changes and they're kind of entirely lost, right?
So it's on one hand, we've built these things that you can train and they do a thing.
But maybe they can't adjust so much.
So is one of the new areas of like, how do you evolve like a deep learning model or something like this?
Yeah, this is a big area of deep learning research is the ability to generalize across tasks.
So you would be able to take your example, AlphaGo, the deep learning model that has been defeating the Go champions across the world,
and try to generalize that to maybe just a slightly different game board.
You can use a larger game board, for example, or even generalize that to a different game entirely, like chess or something.
But here at Vicarious, we're taking a bit of a different approach.
We aren't using deep learning as much as other AI research shops around.
We specifically are taking a more structured model-based approach using probabilistic graphical models.
And we're finding that our models and algorithms are much more attuned to things like generalization and unsupervised learning,
which are some problems in the deep learning community.
Yeah, yeah.
That sounds so interesting to work on.
So maybe tell us, like, most of us listening know what it's like to write software, create some utility, write a web app, or whatever.
How does, like, working on AI research projects, how much is that the same or different than writing a web app?
Well, the workflow is pretty similar to a lot of software engineering companies out there.
At a high level, it's really just agile practices.
We iterate and move very quickly.
But the difference is these are through experiments, experimenting on our models and algorithms, not really through product releases.
Right.
You don't just plan it out and say, these are the features we want.
I'm just going to build them.
Because you don't necessarily know what the answer is, right?
Yeah, exactly.
So we don't have a Kanban board of tasks and picking up and everything that you discuss at Scrum or something.
It's a lot more loose than that.
And researchers here, a lot like developers in agile workflows, have a lot of freedom.
And we need that to come up with these short-term ideas and long-term ideas and flesh them out and experiment out them.
So when we're building our code bases and our experiments, well, I like to think of developing and software engineering code into kind of three classes.
There's research, prototype, and product code.
And we mostly dabble in the research and prototype code, where research code is you're quick and dirty.
You're moving fast through experiments.
Hackey code is okay.
Test coverage is usually discouraged because it slows you down.
And then prototype is a step up where we want well-designed, well-architected for data flow and interfaces.
We want unit and integration test coverage, style standards like pet bait, and documentation.
But still, the mentality is this is code that will someday be scrapped.
So you're not married to it.
It doesn't have to be beautiful 99% test coverage.
Yeah, that makes a lot of sense.
It seems like you just want to play with the code in the beginning.
And then once you have an idea, like, all right, now this looks like it's going to work.
Let's go try to, like, really build this out and see what this does.
Well, almost.
The workflow is a little bit different because it really starts with theoretical and mathematical foundations.
So when we get some sort of research idea, if it's defined as just a problem that you want to try to solve or some new constraints on a different experiment, we first go through, okay, what are the mathematical foundations of this?
And we derive things like message passing algorithms over factor graphs.
And then we take that math and abstract it into software.
And that's how we build our experiments.
And then we do simple little toy problems of these experiments to really inspect the models and algorithms.
And then we get into things like building well-designed software and everything.
Sure.
And do you guys use Python for a lot of this?
Yeah, absolutely.
Python is the main language that we use here.
And it's really becoming ubiquitous in machine learning and AI.
It's elegant with a really simple syntax.
We can iterate quickly.
And it's relatively easy for people to learn.
A lot of AI researchers come straight out of academia and just toiling with MATLAB for their PhD for five years.
So they need to learn how to actually program.
And Python is great for that.
And then on top of that, Python is really powerful.
I love the phrase batteries included.
There's so much that comes with the standard library and then tons of PyPy packages that you can throw on top of that.
And Python sometimes gets some flack for being a little slow.
But it's really easy to control a C++ backend and integrate with some C or C++ code.
Right.
So maybe you prototype it out and this part is not quite fast enough.
So you could say, well, let's write this in Cython or write in C++ and then bring it into our Python app or something like that.
Yeah, absolutely.
Of course, we profile and optimize algorithms first.
So if an algorithm is something like ON squared because we have nested for loops but can be refactored into something sublinear, we do that.
And then we do more profiling and see, okay, this is really a bottleneck.
Let's port it to Cython.
Yeah, sure.
So that's a really good point.
Even though maybe you could make it run 10 times faster or something in Cython, if you have an algorithm that has a super high complexity, it doesn't really matter, right?
If you're going to have to take more and more data, it's really the algorithm that's the problem.
And a lot of people have pointed out that working in Python, it's easier to conceptualize and evolve the algorithm.
And then if you have to, to optimize it further, right?
Oh, yeah.
Yeah.
It's pretty straightforward to have an idea and then say, okay, I'm going to implement this in some nested loops, but God, this is awful and ugly.
And I'm just going to put it to do and come back and vectorize this.
And then you come back and fix it.
And it's just magnitudes faster.
Nice.
So maybe tell us a little bit of some of the tools that you use, like Python is pretty obvious, but things like TensorFlow, Carreras, NumPy, SciPy, those types of things?
Yeah, yeah.
We use TensorFlow for some of our projects.
It's really becoming very popular in the AI and specifically deep learning community where distributed computing over tensor graphs is really valuable.
Yeah.
Maybe for people who are not familiar with TensorFlow, just give them a quick elevator pitch.
What is it?
Oh, sure.
So TensorFlow, it's offered in more than Python at this point, but the main API for it is Python.
And it abstracts away a lot of the C and C++ computations for parallelizing tensors, which are basically just symbols that are distributed over these computation graphs.
And they offer some really cool tools for visualizing these computation graphs as you're doing things like training your model distributed across clusters or running inference on these models too.
Nice.
Okay.
Yeah, perfect.
And what are the other ones that you use?
Well, just like any software company, we try to leverage external tools.
We're not trying to reinvent the wheel here.
So a lot of our vision utility functions, for example, are handled with toolkits like OpenCV, which is C++ with Python bindings.
So a lot of that is pretty fast.
And SciPy, like you mentioned, for operating on NumPy arrays like Gaussian filters and convolutions.
It sounds like there's a lot of math involved and some pretty interesting programming.
Do you have like cognitive science people doing almost like brain modeling work?
What other disciplines are trying to like work together to solve this problem there?
Yeah.
So there's definitely a lot of math involved.
And actually, when people come to me for advice and say, hey, I want to get into AI research.
And one piece of advice I give them is you need to have your first language be math and then whatever programming language come after.
Sure.
And so give us a sense of like how much math.
Like if I was, say, super good at differential calculus, but that's all I knew.
Is that enough?
Do I need to know like statistics and probability?
Do I need to know linear algebra, graph theory?
Like what, when you say math, is it a PhD or is it a minor?
Well, we do have a lot of PhDs in things that are just obscenely complicated and impressive.
And those are across computational neuroscience to theoretical math.
But I would say graph theory, like you mentioned, specifically modeling and running computations over probabilistic graphical models is very important.
And the foundations of which are in probability and linear algebra.
Okay.
So not super out of touch math, but you definitely need to be able to speak those things.
Oh, no, yeah.
Yeah, like a pretty good, not first language necessarily, but second language.
Sure.
Okay, sure.
This portion of Talk Pythonemy is brought to you by Linode.
Are you looking for bulletproof hosting that is fast, simple, and incredibly affordable?
Look past that bookstore and check out Linode at talkpython.fm/Linode.
That's L-I-N-O-D-E.
Plans start at just $5 a month for a dedicated server with a gig of RAM.
They have 10 data centers across the globe.
So no matter where you are, there's a data center near you.
Whether you want to run your Python web app, host a private Git server, or even a file server, you'll get native SSDs on all the machines, a 40 gigabit network, 24-7 friendly support, even on holidays, and a seven-day money-back guarantee.
Want a dedicated server for free for the next four months?
Use the coupon code python17 at talkpython.fm/Linode.
It seems like a really fun thing to do, right?
Like every day you come in and people have new ideas and you try them and you're kind of exploring new space, right?
Yeah, absolutely.
There's not really a defined path to AGI.
And we try to build it from like, what do you think an artificial agent is in the world?
It is sensory perception.
It's goal-directed behavior.
It's building a model from sensory motor interactions.
And from that, we try to derive the fundamental properties and constraints of intelligence.
And that leads to our research ideas and eventually experiments.
Yeah.
So you talk about like open CV and computer vision and sensory stuff.
How much of what you're working on do you hope exists in the real world?
And how much are you thinking like if we could make a digital thing that could just live, say, on devices, on the internet, and only interact digitally, right?
Not actually see the world, but, you know, interact with people, say, with voice or text or things like that.
Hmm.
Interesting.
So at Vicarious, we're specifically building AI towards robotics.
Any robot, any task, we build the brain for it.
That's our initiative here.
So a lot of it is in the physical world.
And me specifically, I'm focused on our main vision team here.
Nice.
And how much of this do you see as like a consumer sort of thing versus, say, like factories?
Are you focused on doing this for people or for companies or I guess that's the question?
Yeah.
So there's not so much I can really share about the specific robots and applications that we're building.
Don't share your secrets.
I don't want those.
But the idea is like we want to build general AI.
So all of the things.
Yeah.
That sounds really cool.
What are some of the other companies that are doing this type of work?
Like I know what maybe companies are using it, but like AI research is a pretty small group of people I would expect.
You're right.
There's a lot of companies out there using AI, practicing AI.
But for doing the nitty gritty fundamental research, the shops are namely OpenAI, DeepMind, which is out in the UK.
And they were acquired by Google some years back.
And us, Vicarious.
Okay.
Now that's a pretty small group.
There's also Google Brain.
Yeah.
Do you know what the relationship between like Google Brain versus DeepMind is?
They're not even the same continent, right?
No.
And I've heard some conflicting information from people on the Brain team and people on the DeepMind team.
But as far as I can tell, DeepMind is kind of a separate entity.
They don't interact too much on projects.
DeepMind is much more building towards general AI.
And Google Brain does AI research, but a lot of it is directed more towards the applications for Google.
Sure.
Makes sense.
Do you consider companies like Uber or, you know, Google Alphabets, Waymo, sort of self-driving car type things?
Would you put them into this bunch?
Or do you think of them more as like using AI?
I would say using AI.
So my understanding of a lot of these companies, specifically the self-driving car companies, is they're looking at what sort of deep learning models can I use for my vision problems, my LIDAR sensor problems, and my motion planning problems.
And they'll take existing models that are out there from toolkits such as TensorFlow or PyTorch or Keras even.
And then they'll tweak those for their specific problem.
So that's more of a hyperparameter tuning type work, not so much the real fundamental research.
Right.
Okay.
And a lot of these guys are open sourcing their tools like TensorFlow and whatnot.
And I think there was even like a pact about this.
Like Google and Microsoft and some other people, didn't they team up on like sharing their research and their work?
It's been like a year since I've heard about this.
So my details are flaky.
Sure.
Well, there's been some collaboration over sharing these research environments.
So like I mentioned, video games are often a testbed that we use a lot.
So Microsoft has developed Minecraft to be a testbed for AI development.
And OpenAI has released their gym for different AI agents.
And then also Universe, which is just a big collection of all these different games.
And I believe there was some collaboration or teamwork between the two of them.
Okay.
Cool.
Yeah.
Universe sounds, I heard about that a while ago.
That sounds really pretty wild.
And as an AI research company, do you guys find stuff like that useful?
Like, hey, I could take this AI and drop it into Counter-Strike or I could drop it into Pitfall and all these different places where it can interact.
Is this helpful?
Yeah.
Definitely helpful.
We haven't explored Universe so much here at Vicarious, but we also build some internal environments that are very similar.
Mainly, we use internal tools because then we can define an API that might give us some different information than some of those APIs exposed.
But it's definitely helpful to have a lot of testbeds and use cases out there.
Yeah.
It seems like if you were, say, a grad student writing a master's thesis, being able to just plug into different video games is like a super big boost.
But if you're a full-on mini-person AI research company, you need something that you can, like, exactly tweak the environment just so.
Like, I want to understand how the robot interacts with, like, the squishiness of an object, right?
Yeah.
Which you probably can't get in, like, Unreal Game or something, right?
Yeah.
Exactly.
And a lot of this open sourcing is specifically targeting those grad students in universities.
I see open sourcing these toolkits and also for the same reason why all these companies are publishing a lot of their papers as a recruiting tool.
Yeah.
Because a lot of AI researchers are very academic at heart.
We want to share our information and help each other.
So the more that these big companies are sharing and being open about what they're building, the more they can attract top down.
Yeah.
So companies like OpenAI and Google might have a better chance of getting somebody who's mostly interested in the research side of things than, say, Apple.
Yeah.
Exactly.
This has been a problem for Apple as of late.
Yeah.
I guess there's a couple questions around universities, like, you kind of touched on.
One is, do you know if there are, like, machine learning AI bachelors these days?
Hmm.
Or is there just computer science and you can focus on that?
You know, I don't know if you can major exactly in AI or machine learning, but there are definitely a lot of undergraduate courses that you can take.
And from what I've heard, these courses are becoming ridiculously popular.
I try to mentor a couple of students from, like, Stanford and CMU.
And I always tell them, like, oh, there's a probabilistic graphical models course.
You have to take that.
Yeah.
That's cool.
It seems like there'd be a lot more money in working at Google on TensorFlow or maybe with you guys or whatever, rather than, say, being a professor at a university.
Is there, like, a drain of, like, as professors sort of get their research going, do they get sucked out of academia?
Yes.
For a typical example.
I know it's a problem for data science.
I just don't know about machine learning.
It seems like there's a parallel, right?
Yeah.
Oh, there absolutely is.
Now, the main example of this is Uber going into Carnegie Mellon and grabbing, really, all of their computer vision researchers a few years back.
But I think you largely see more of a collaboration in sorts.
So sometimes top professors from universities will have appointments with some companies like OpenAI or Google, and they'll still work with their universities and their research labs on some of their projects, but at the same time work with the industry partner in a way.
And that also works as an incredible recruiting tool for these companies.
Yeah.
And it also seems like it's probably the best of both worlds, right?
You still get to be a professor.
You still get to do your research and teach people, but you also get some real-world experiments and experience.
You're not just, you know, in your lab poking around, right?
You get to see really what people are trying to do with it.
And there's a big difference between trying to just fill out grants and get money and resources through academia versus having some sort of private or public company.
And if you need just infinite AWS clusters, you can get it.
Yeah, like I need 100 GPUs in a cluster.
Can we do that?
Yeah, sure.
Here, you push this button.
Yeah, yeah.
It was kind of funny.
Someone did a blog post on like huge spike in AWS GPU demand the week leading up to the paper deadline for NIPS, which was like a few weeks ago.
It is impressive.
Yeah, we've got to finish our research.
We've got to get this going.
Yeah, it's...
Yeah, yeah.
Yeah, so you guys probably do a lot of cluster computation stuff like that.
Do you use GPUs and other specialized chips or anything?
For some of the models that can take advantage of the parallel compute on GPUs, like deep learning models, yeah, absolutely.
But a lot of our larger models are still used on AWS, but not necessarily GPUs.
Just straight EC2 clusters or something like that.
Yeah, yeah.
Yeah, all right.
Very cool.
So we talked about the math requirements, linear algebra, calculus, probability, things like that.
But if people, you know, they want to try this out and they want to get started, like how maybe they know Python, but nothing else.
Like how would they get started?
I would recommend getting inspired by a model or a problem, maybe a NIPS paper or something from ICML or even a blog post that shows some pretty cool results on like natural language processing.
And dive in that way.
Yeah.
Do you have some examples of like what a problem might look like?
Would they have those at Kaggle?
Yeah, absolutely.
That's exactly how I got inspired.
Going to Kaggle and there are a whole slate of machine learning problems that you can dive into.
And oftentimes those communities will discuss their approaches and share some of their methods.
So that is really good, almost a code first way to dive in.
But like I was saying earlier, to build up the math chops to really be able to do AI research, I recommend trying to reproduce paper results.
So you pick out a research paper and you go through it.
You try to understand the models and the algorithms, the assumptions, the experiments, and then you try to implement that from scratch.
It's not easy.
You're going to fail a lot.
But it's the best way to learn.
And fortunately, if you're doing this in Python, a lot of the Python community is very helpful.
Yeah.
So what are some of the tools?
Maybe the ones we talked about, TensorFlow, Carreras, things like that?
TensorFlow and Carreras, they have some great prepackaged models that you can take out of the box and even some that point specifically to the papers that they're from.
So you can get up and running pretty quickly.
Yeah.
Maybe a really simple way to get started might be to take somebody who's written a paper, done some project, but it's only in MATLAB, and say, let me try to reproduce this in Python.
Like, just even started from their code, right?
Yeah.
That's a good idea.
You kind of, like, take it, like, let me not actually try to solve the problem, but just take it technically through the steps of, like, creating it in Python and seeing how that goes.
And then you've kind of got that experience.
And then you can go and try to, like, actually solve it independently.
Yeah.
Ultimately, it comes down to just trying to build a link, a mental model of how the math is connected to the software implementation.
And if that's building the code and then trying to figure out how the algorithms and equations are defined there, that works best for you.
Go for it.
If it's more of a bottom-up approach, do that.
Yeah.
Cool.
So you talked about your dev workflow being very sort of loose, and you start from just let's play around and not worry too much about patterns and factoring our code and doing testing stuff.
What are some of the pain points that you might end up with from, like, that workflow?
Because we move fast and it's a lot of research and prototype code, we can build up some technical debt.
And this largely comes because people, researchers here, want to build the next thing, not put in another few days to refactor their experiment into beautiful abstractions with 99% test coverage.
And they're probably, they're researchers, right?
There's more mathematicians and scientists, not pro developers who really care about, like, this design pattern or something, right?
We have a mix, fortunately.
So there are some that are very academic researchers who just do some kind of ugly things in the code.
And fortunately, we have our code review, our pull request review process that can help teach them and be a tool for building better software engineers.
But then we also have a lot of people here that are very strong engineers and have built up their software chops coming from companies like Google or Facebook.
Yeah, of course.
And that's pretty serious development right there.
Yeah.
So do you use, like, special, like, any particular tools for, like, refactoring code or for profiling or things like that?
Yeah.
So profiling code is really useful around here because, I mean, the biggest mistake a program can do is trying to optimize our code without actually knowing where the pain points are.
Yeah.
I find that even harder in this type of computational stuff where it's sometimes not intuitive.
Yeah.
And Python comes prepackaged with some useful profilers.
I prefer to actually use Kernprof line profiler because some of the Python built-in profilers will really just show you, like, this function is your bottleneck.
But going line by line, I've found to be much more helpful.
Yeah, sure.
So, yeah, here's a 100-line function.
It's slow.
Like, great.
That helps me a lot.
Yeah.
Yeah, exactly.
And maybe, I guess also, if you had your code more factored, right, into little methods and things like that, breaking across even packages and things, maybe it's easier for it to say, well, this is slow.
Like, okay, well, I clearly see the function that is slow.
But if you're just playing around and experimenting, like, you maybe don't have it so fine-grained, right?
So it's even worse than normal, maybe.
Well, we try to keep our code well-designed for both conceptual level and practical level, where conceptual is like functions and objects are abstracted to follow the math.
Practical is more of running end-to-end experiments efficiently.
So conceptual is important because we want well-designed code so we can extend it naturally with future research.
So that might be where things like computational bottlenecks aren't really obvious.
But when you try to run these experiments end-to-end, that's when you see, like, oh, well, we need to go back and profile and optimize.
Yeah.
Yeah, that makes sense.
Yeah, so that kind of touches on, like, this tension between research and software priorities.
Yeah.
How do you keep those in balance?
Like, what are the trade-offs there?
Well, it's interesting because the research rewards, experiment results, and maybe sharing some cool figures and visualizations with the team are more near-term.
While the software rewards, like benefits of a clean, well-documented code base, those are farther off.
So it makes it difficult to prioritize good software like refactoring and cleaner abstractions.
I found it very helpful to try to communicate, overly communicate, actually, the value of high-quality software.
Like, maintainable code base makes onboarding new engineers much smoother, and they can get up and running and contributing much faster.
And then also, I try to reward, in a way, examples of good code.
An example recently was there was a good use of Dunder slots for fast attribute lookup in a PR I was reviewing the other day.
Yeah, so maybe tell people about Dunder slots.
Like, it's used in the right time, in the right place.
It can, like, dramatically change memory and performance, and it's interesting.
But we haven't talked about it much in the show, so what's Dunder slots?
Oh, sure.
So my understanding of it is, basically, when you have a class in Python, and you have attributes for that class, it automatically will create this Dunder dict object.
And if you don't need that representation for every attribute of your class, it could be a lot of overhead to do lookups in that Dunder dict.
So sometimes you can use Dunder slots, which avoids the creation of Dunder dict, and you can define your attribute lookups there.
That sounds right.
So there's, you can put in a class just anywhere, and just say Dunder slots equals, and you give an array, a list of basically the field names, the variable names.
And then those are the only variables it can have, right?
So in normal Python classes, you could dynamically add another field to it, or things like this.
And it uses that Dunder dict to manage that.
But every instance of the class has a separate dictionary with separate names of the keys and things like that.
And so the slots basically means there's none of that, none of that creation, allocation, assignment, all that kind of stuff.
Yeah, so it's really amazing.
All right, so somebody did this, you're like, oh, wow, look at this thing.
Yeah, so it was just like a quick shout out on our Slack channel, just saying, hey, this is awesome.
Prop to somebody, yeah, that's really cool.
Yeah, yeah.
This portion of Talk Pythonry is brought to you by us.
As many of you know, I have a growing set of courses to help you go from Python beginner to novice to Python expert.
And there are many more courses in the works.
So please consider Talk Python training for you and your team's training needs.
If you're just getting started, I've built a course to teach you Python the way professional developers learn by building applications.
Check out my Python jumpstart by building 10 apps at talkpython.fm/course.
Are you looking to start adding services to your app?
Try my brand new consuming HTTP services in Python.
You'll learn to work with RESTful HTTP services as well as SOAP, JSON, and XML data formats.
Do you want to launch an online business?
Well, Matt McKay and I built an entrepreneur's playbook with Python for Entrepreneurs.
This 16-hour course will teach you everything you need to launch your web-based business with Python.
And finally, there's a couple of new course announcements coming really soon.
So if you don't already have an account, be sure to create one at training.talkpython.fm to get notified.
And for all of you who have bought my courses, thank you so much.
It really, really helps support the show.
So I looked at the Vicarious website to sort of check out what you guys are up to.
And I looked at the team page.
And there are a lot of people that work there.
Way more than I expected, actually.
How many people do you work with?
So we're at about 50 now.
And I started eight months ago, and I was number 30 or so.
We're growing a lot.
And we're looking to keep adding more engineers and researchers.
And we're expanding also to a big new office building and everything out here in San Francisco.
And there's a lot of us here.
And the really interesting thing is that there's a lot of us from very diverse technical fields.
So we have some people that are theoretical neuroscientists, some people that specialize in robotic grasping and manipulation and everything in between.
Sounds like a pretty cool space to be in.
Yeah, yeah.
It's fun.
Nice.
So you guys are working on this general artificial intelligence, which is maybe the most controversial kind, but also has the greatest possibility for helping society out, right?
Like, it's one thing to make a car that can drive itself.
It's another to make like a robot that can do all these different jobs, right?
And learn and so on.
So, you know, Elon Musk came out with his statement that we're living in a multiverse and he's scared of AI and things like that.
Like, how do you guys, do you guys talk about this kind of stuff?
Do you put any credence in it?
I'm not so sure about the multiverse.
I'm pretty skeptical of this.
But the thing becoming too smart, is this something that you guys actually are seriously concerned about?
It's something that we seriously consider.
I wouldn't necessarily say concerned.
It's funny.
Whenever I meet random people and say what I do, I end up having this conversation a lot.
I bet you're like, oh my gosh, here we go again.
Yeah.
No, we're not living in a multiverse.
This is just like, damn off the...
Well, AI will do amazing things for society, like transforming healthcare from reactive medicine to something that's predictive.
And essentially eliminating motor vehicle accidents.
I dream of the day I can ride my bike around San Francisco and not worry about someone slamming into me.
Yeah.
Yeah, absolutely.
But on the spectrum of fear and optimism, where the former are guys like Nick Bostrom, who wrote that super intelligence book.
Yeah.
Elon Musk and the latter, where the optimists are those of like the futurists, Ray Kurzweil.
I would say most AI researchers, and myself included, fall somewhere in the middle, leaning towards optimism.
So I would say, as with previous technological revolutions, there's definitely concern over the big societal changes, and rightfully so.
Jobs will be lost to automation and industries transformed.
But it's much easier to look at the existing jobs as examples, painting the picture of, oh, wow, AI is going to replace all of these, we're going to lose all of these jobs.
Than it is to imagine a future where there are new industries that are yet to be created and all the jobs to find.
Every change in human history has not wiped it out and people just went and sat in the corner, right?
Like the industrial revolution, the move away from farming, the move to knowledge workers, like all of these things have been done.
Exactly, exactly.
We will go on.
But I would say the real concern is the speed with which this transformation will take place is significantly faster than the agricultural and industrial revolutions.
Fortunately, companies are taking this into real consideration.
Elon Musk's OpenAI is one.
Here at Vicarious, we have a group dedicated to AI ethics.
Oh, wow.
Okay, that's pretty interesting.
Yeah, I definitely think the change will go quicker.
You know, like the change for the industrial revolution, things like that, they banned people's working careers.
So it's not like next year the thing that you did was completely gone and it was totally fine the year before, right?
And so I think there's going to, I think you're right, there's probably going to be some kind of step where there's like a serious shakeup.
One example of this that comes to mind is the U.S.
The number one job title, job role for men is driving of some sort, like trucks and things.
You know, self-driving cars, self-driving trucks and semis and deliveries could put a serious dent in, you know, guys' jobs.
And if that happened too quickly, I can see like some serious social unrest because if you have a large young group of men who are not employed and have no positive outlook, that could really turn badly, right?
Yeah, it could.
And you see some early examples of this with companies like Uber and Lyft who aren't necessarily replacing drivers, but they're transforming an industry in a way where taxi drivers are the source of this unrest because now they've opened up the workforce to this kind of car sharing or ride sharing.
Yeah, I would say it's similar to what the Internet did for knowledge work, right?
Like it used to be you would go to your office and you would compete with the people in your city for those jobs.
And then all of a sudden the Internet came along and open sourcing and globalization and everything.
You were all of a sudden competing with everybody, not just the people in your town.
And it's a little like that.
Like how many people are going to actually go and become taxi drivers versus like, hey, I have a car.
I have a smartphone.
I got two hours and need some money.
Let's just go do it, right?
It really opened up the space of potential people in the marketplace.
Yeah.
I agree that there's we'll probably get through it pretty smoothly and there's there's very likely going to be something amazing on the other side.
Let's think maybe one more question on this on this theme for you because I know you I know you have these questions a lot.
But what do you think the biggest change that AI is going to bring that people will like obviously notice?
Right.
Not something super subtle that makes a change that they don't necessarily see.
But like what are people going to go?
Wow.
Like here's what AI has brought us in 10 years or 20 years.
Well, it's kind of like the mountain climbing dilemma that we were talking about earlier where new AI technologies roll out, but it's very incremental in a way.
And you don't necessarily notice that Facebook's algorithm for identifying whose faces are whose has improved a lot.
But it did.
And that was the outcome of some really impressive AI research.
But something that I think I hope people will look at and just be completely floored by is how AI is going to transform health care and medicine.
Yeah, that's one of the things I definitely think as well is diagnosis basically.
Yeah.
Like I had mentioned earlier, health care has always been very reactive.
Someone is sick and has some sort of symptoms and we guess at what is going on.
And that is all suspect to what kind of quality of health care you can see.
And fortunately, we live in a country where we have a lot of good health care doctors.
But in third world countries, this absolutely is not the case.
AI I see as more less diagnostic, more preventative in a way.
So you know that you're getting sick months before you actually show any symptoms.
And the treatment is minor instead of catastrophic.
Yeah.
Interesting.
So one of the rumors, you know, there's not an iPhone 8 yet, but one of the rumors around the new iPhone coming out is that Apple is working on a dedicated AI chip that goes in the iPhone.
What do you think of these types of developments?
This is really interesting because we've been hearing for years a lot about this neuromorphic chip development, which was basically companies like Intel and ARM or whatever doing some research towards, okay, what is the next platform for computing?
And recently we've seen or heard about Apple's new chip.
And Google also has their TPU, which is a Tensor Processing Unit.
And these are devices dedicated to running specifically their algorithms on devices, I guess, on iPhone and iPad.
And I don't know too much about the hardware of these devices, but they would be optimized for computing inference on deep learning models and such.
Yeah.
I think it really opens up the possibility for something interesting, but I have no idea what it's going to be.
We'll find out in a few years, I guess.
Yeah.
The exciting thing is a lot of the work in AI is no one knows what it's going to be.
Yeah.
That keeps it fun.
All right, Alex.
Maybe we should leave it there for the AI topic.
I really appreciate you sharing what you guys are up to and your thoughts on AI research.
Yeah.
I'm glad you guys are interested.
Yeah, it's cool.
All right.
So now it's time for the final two questions.
So when you write some of your deep learning Pythonic code, what editor do you open up?
Oh, I definitely go for Sublime.
There are some add-ons like GitGutter I like a lot and PyFlakes Linter.
And then for C++, I'll use CLion.
Yeah.
Okay, cool.
Yeah, definitely the plugins for Sublime are cool.
And I played a little bit with CLion, but I just don't have enough C++ code to write.
So it looks neat, but I haven't done anything with it.
And notable PyPI package.
Oh, there's so many.
The one I mentioned earlier, KernProf Line Profiler, has saved my neck many times.
And then also, I like working from the command line a lot.
A lot of people in research will use Jupyter Notebooks for the interactive visualizations.
But working from the command line, I like PTPython.
Oh, yeah.
I love PTPython.
That's great.
Yeah, I use that as well.
Yeah, the tab complete is so clutch.
But then also, arg parse, I love a lot because I can just throw an experiment in a script and
then have some parameters that I define at the command line.
Yeah.
All right.
Awesome.
Those are three good recommendations.
So final call to action?
Well, if you're trying to get into AI research, like we were discussing earlier, you can definitely
check out some of these toolkits that have prepackaged models like Keras and TensorFlow and PyTorch.
But you should try to implement, for example, a convolutional neural net in numpy code.
That's how you really learn what's going on.
All right.
So let's start from the ground up and figure it out.
Then use the tools, huh?
Yeah.
All right.
Excellent.
So thanks so much for being on the show and sharing your story with everyone.
Appreciate it.
Yeah.
Thank you for having me.
You bet.
Bye.
This has been another episode of Talk Python to Me.
Today's guest has been Alex Lavin, and this episode has been brought to you by Linode and
Talk Python Training.
Linode is bulletproof hosting for whatever you're building with Python.
Get your four months free at talkpython.fm/Linode.
Just use the code Python17.
Are you or a colleague trying to learn Python?
Have you tried books and videos that just left you bored by covering topics point by point?
Well, check out my online course, Python Jumpstart, by building 10 apps at talkpython.fm/course
to experience a more engaging way to learn Python.
And if you're looking for something a little more advanced, try my Write Pythonic Code course
at talkpython.fm/pythonic.
Be sure to subscribe to the show.
Open your favorite podcatcher and search for Python.
We should be right at the top.
You can also find the iTunes feed at /itunes.
Google Play feed at /play and direct RSS feed at /rss on talkpython.fm.
Our theme music is Developers, Developers, Developers by Corey Smith, who goes by Smix.
Corey just recently started selling his tracks on iTunes, so I recommend you check it out at
talkpython.fm/music.
You can browse his tracks he has for sale on iTunes and listen to the full length version
of the theme song.
This is your host, Michael Kennedy.
Thanks so much for listening.
I really appreciate it.
Smix, let's get out of here.
Stay tuned.