hi my name is Emily Weber and I'm the
machine learning specialist at Amazon
Web Services today we're gonna be
talking about Amazon sage maker I hope
you enjoyed our previous two videos
first we learned about notebook
instances then we learned about using
the built-in algorithms now we're gonna
learn about bringing your own model this
is your deep dive so first there are
many ways to train models on sage maker
right and so the first one is using the
built-in algorithms but it just grows
from there there's also a technique
called script mode you can bring your
own docker container you can leverage a
solution on the AWS machine learning
marketplace or you can just train on
your notebook instance in this scenario
we're gonna learn about options number
two three and four first off script mode
so script mode means that Amazon sage
maker is managing a docker container
that is an AWS managed container that
lives in ECR already how do you want to
write your own model that's pretty much
the primary question you need to ask
when you're using script mode and then
you're gonna want to pick one of the
open source containers that we are
actively managing so that's gonna cover
MX net tensorflow PI torch scikit-learn
spark ml and chain er so we're gonna be
managing those containers you write the
code for your model and then you put it
inside those containers and then it can
run on the sage maker training jobs in
particular first you want to point to
the AWS managed container of your choice
write your model which can be a single
file or a bundle of files specify your
entry point within the sage maker
estimator and so that's the location of
your file so if your file is sitting two
directories above or if it's the name of
the file and it's in the same directory
then just take the name of the file and
then you'll just put that straight in
the sage maker estimator include any
extra libraries that you're gonna have
with a requirements txt file and then
when you use the script mode managed
containers you're also gonna get to use
our webserver so when you're interested
in running inference with that model
you're gonna be able to leverage a
managed web server okay when you bring
your own docker file this is what's
what its gonna look like you're gonna
import from the stage maker examples you
can install any libraries that you need
to you can run additional installations
and then in this case there's a
copyright so there's a copy on Mars are
into opt ml and then this copy of
plumber are into opt ml and so
everything with inside sage maker is
looking inside optimal so it's gonna be
looking directly within that location
before your both your models and your
inference code and then in this case
we're specifying the entry point as mrsa
dar so just to walk through that when
you bring your own docker file that
means you as the customer are managing
the creation of that container and the
registry within ECR that means that you
can write your model however you please
you'll want to point to your model
within your docker file you'll want to
register that container on ECR and
you'll want to point to your containers
address in ECR within your stage maker
estimator and then don't forget to
implement a serve function so even if
you're just doing the training we're
still going to check for a function
that's called serve and so make sure you
have something implemented there great
so we talked about script mode then we
covered bring your own docker container
the AWS machine-learning marketplace is
a way that you can access other
algorithms to Train on Sage maker both
algorithms and models an algorithm means
it's a set of code that you can train on
your data set a model means it's a pre
trained model artifact and you're just
going to access it and then use it
within your environment both of those
are available on a subscription model
and the good news for us is that there
is absolutely a free tier so you can
absolutely check out some of these
solutions for free many of them are
gonna fall into a number of these
categories so whether that's image audio
vision text and there are over 230
solutions that are available on the AWS
machine learning marketplace today ok
let's take a look at an example so in
this case we're just gonna cruise down
here so I'm at the stage maker examples
tab under advanced functionality I'm
gonna select our bring your own
I'm gonna use on that we're gonna create
a copy and then same scenario I'm just
gonna enter an s3 bucket here so let's
do this
now we're gonna import sage maker and
then our bucket is gonna be a sage maker
dad session dad default bucket let's
make sure that's looking good great okay
then I'm just gonna run everything below
all right so this is an example where
we're bringing her own our model and the
flow is pretty similar we're importing
sage maker we've got our bucket in our
session we need some permissions I'm
gonna open up the our model so you can
see it and here's our new folder and
here is the our model that we're
actually looking at so that's Marie
start you'll notice that the prefix is
optimal we've got our input output model
path a channel name we're gonna learn
about that in the next session and then
here's our training function we've got
our parameters we've got our target I'm
gonna read in our training files we've
got our model right here then we're
gonna fit it and write success and
there's also the serve function right
here and that's actually using plumber
and then just to check out the docker
file so we are pulling from the sage
maker example maintainer installing
those are based libraries copying it
into ml into optimal then specifying
that entry point and then just to show
you the estimator here about this
example is run in so this is the set
where it's actually publishing an ECR
and then down here are the training
parameters so this is the actual image
right and so it's actually within ECR
exactly here's our training cluster also
going to learn about in a second here
all right then we call modeled outfit so
there we go
a couple pro tips so again the three
ways that we're learning about your
script mode bring your own docker file
in machine learning marketplace
certainly the school the script mode is
gonna be a lot faster to train your own
model on you are gonna be limited to
those managed limited to those managed
options so if you need to maximize your
flexibility go ahead and bring your own
docker file it can be a little bit more
time consuming cuz you actually have to
build an entire docker file however you
can absolutely test it locally so you
can't ask the creation of your docker
file on your notebook instance before
actually setting it up to ECR
and then obviously on the machine
learning marketplace you can move very
quickly there are hundreds of options
that are available on the marketplace
you can find one and get to use it right
away just remember that sage maker
within the container is gonna read from
opt ml and definitely find an example
that fits your needs whether that's
using Karis tensorflow MX net PI torch
or any specific framework or scenario
that you're looking at find that example
run through it and make sure that you
understand how it works and then just
modify it and it will absolutely work so
thank you very much that's all I got my
name is Emily Weber I'm with machine
learning specialist at Amazon Web
Services thank you for your time go
ahead and check out our github site
amazon sage make your examples
you