亚马逊深度学习库_关于亚马逊智者的深度学习的非常简单的介绍

亚马逊深度学习库

介绍 (Introduction)

In this article, I will walk you through loading your data to S3 and then spinning up a Jupyter notebook instance on Amazon Sagemaker for running deep learning jobs.

在本文中,我将指导您将数据加载到S3,然后在Amazon Sagemaker上构建Jupyter笔记本实例,以运行深度学习作业。

The method I’m about to review is not the only method for running deep learning in the cloud (in fact it’s not even the recommended method). But this method is a nice way to get started.

我将要回顾的方法不是在云中运行深度学习的唯一方法(实际上甚至不是推荐的方法) 。 但是这种方法是入门的好方法。

PROS:

优点:

  • Easy to transition to the cloud! Say I want to run my already established code on a larger machine, or I don’t have a local GPU and I want to run a longer job without Google Colab timeouts, then this method should allow you to get up and running on AWS with fewer code changes!

    轻松过渡到云! 假设我想在更大的机器上运行已经建立的代码,或者我没有本地GPU,并且想在没有Google Colab超时的情况下运行更长的工作,那么该方法应该可以让您通过以下方式在AWS上启动并运行更少的代码更改!
  • Once you’ve mastered this method, you can move on to more robust options.

    掌握此方法后,您可以继续使用更强大的选项。

CONS:

缺点:

  • Currently, Sagemaker does not have auto-shutdown for notebook instances. Why is this important? Well, say I run a training job and then I go see a movie. When I get home, my notebook\GPU instance is still running even if the job finished hours ago. This is not good because I’m paying for that time (and GPUs are not cheap). So you basically can’t leave your machine alone and un-monitored with this method.

    当前,Sagemaker没有针对笔记本实例的自动关闭功能。 为什么这很重要? 好吧,比如说我从事培训工作,然后去看电影。 到家后,即使作业在几个小时前完成,我的笔记本\ GPU实例仍在运行。 这不是很好,因为我要为此付出代价(GPU并不便宜)。 因此,您基本上不能让您的计算机处于单独状态并且不受此方法的监视。

Side note: there is a way to auto-shutdown using the “bring your training to Sagemaker” method, but it requires some additional coding. This is an option you can explore if you want.

旁注:有一种方法可以使用“将您的培训带入Sagemaker”方法自动关闭,但是需要一些其他编码。 您可以根据需要选择该选项。

After I walk through creating an S3 bucket and spinning up a Sagemaker notebook instance, I will reference you toward my some code which is stored on GitHub. The notebook on GitHub walks through how to connect to your data in your S3 bucket and then walks through some Hyperopt + TensorFlow\Keras code. In my Hyperopt example, I’m doing hyperparameter search for a recurrent neural network.

在创建完一个S3存储桶并旋转了一个Sagemaker笔记本实例之后,我将向您介绍一些存储在GitHub上的代码。 GitHub上的笔记本介绍了如何连接到S3存储桶中的数据,然后介绍了一些Hyperopt + TensorFlow \ Keras代码。 在我的Hyperopt示例中,我正在为循环神经网络进行超参数搜索。

神经网络超参数调整动机 (Neural Network Hyperparameter Tuning Motivation)

One thing to note that’s not mentioned in the notebook is that Hyperopt is optimizing on negative accuracy. The negative is important. Hyperopt wants to find the minimum of your cost metric, which in my case is accuracy. Therefore, using negative accuracy finds the network with the highest accuracy!

笔记本中没有提到的一件事是Hyperopt在 精度方面进行了 优化 是很重要的。 Hyperopt希望找到成本指标的最小值,在我看来,这就是准确性。 因此,使用 精度会发现精度最高的网络!

Okay, so if you’re reading this article and you’ve probably trained a neural network before. You might have even used sklearn to do neural net random search cross-validation, but you want to take it to the next level.

好的,因此,如果您正在阅读本文,并且以前可能已经训练过神经网络。 您甚至可能已经使用sklearn进行了神经网络随机搜索的交叉验证,但是您想将其提升到一个新的水平。

First off, I recommend reading the following article on hyperparameter tuning. In short, Random Search actually does pretty great without having to run tons of iterations. Also, Kaggle and Google Colab handle Random Search CV jobs pretty well.

首先,我建议阅读以下有关超参数调整的文章 。 简而言之,随机搜索实际上非常有效,而无需运行大量迭代。 此外,Kaggle和Google Colab可以很好地处理随机搜索简历工作。

But okay, we don’t care, we’re willing to run a ton of iterations, we just want to push performance any way we can. You might have run across the following problems…

但是好吧,我们不在乎,我们愿意运行大量的迭代,我们只是想尽一切可能提高性能。 您可能遇到以下问题……

1. Hyperparameter tuning on a neural network takes a LONG time (even with a GPU).

1.在神经网络上进行超参数调整需要很长时间(即使使用GPU)。

2. Running long jobs on any free training platform (ex. Google Colab, Kaggle) usually ends up timing out.

2.在任何免费的培训平台(例如Google Colab,Kaggle)上运行长时间的工作通常会导致超时。

Now what do you do?

现在你怎么办?

Image for post
Photo by Emily Morter on Unsplash
艾米丽·莫特 ( Emily Morter)Unsplash拍摄的照片

Well, you really have 2 options:

好吧,您确实有两个选择:

1. Buy a personal computer with a GPU (which is going to cost you, and a bigger one will be better)

1.购买一台带有GPU的个人计算机(这会花你的钱,越大越好)

2. Rent a GPU on the cloud (also going to cost you)

2.在云上租用GPU(也要花钱)

Personally, I eventually went out and bought a laptop with a GPU, but before I did that, I tried the cloud options. Having a personal GPU is great, but as you progress you’ll find yourself needing more power, and you’ll end up back in the cloud regardless (at least that’s what I’ve found).

就个人而言,我最终出去购买了带有GPU的笔记本电脑,但在此之前,我尝试了云选项。 拥有个人GPU很棒,但是随着您的进步,您会发现自己需要更多的功能,并且无论如何(至少这就是我所发现的),您最终都会回到云中。

Okay, on with the show already, how do we use Sagemaker to build our neural networks!

好的,已经进行了展示,我们如何使用Sagemaker构建我们的神经网络!

步骤1:转到AWS并创建一个帐户。 (Step 1: Go to AWS and create an account.)

https://aws.amazon.com/

https://aws.amazon.com/

Seems like a logical first step. Go to the link above and click ‘Create an AWS Account’.

似乎是合乎逻辑的第一步。 转到上面的链接,然后单击“创建AWS账户”。

第2步:将数据保存到S3 (Step 2: Save your data to S3)

So at this point you should be at the management console.

因此,此时您应该在管理控制台上。

Next, click on ‘Services’ and then ‘S3′.

接下来,单击“服务”,然后单击“ S3”。

Now click ‘Create bucket’.

现在点击“创建存储桶”。

Now follow the prompts to create your bucket, give it a name, etc. Make sure that you pick the region that you’re in. I’m in the east coast US, so for me N. Virginia works.

现在,按照提示创建您的存储桶,为其命名,等等。请确保您选择了您所在的地区。我在美国东海岸,所以对我来说,弗吉尼亚州工作。

If you’re like me, and you’re just playing around with Sagemaker and you don’t care too much about permissions (because none of the information being stored is sensitive) then you can just click ‘Next” for pages 2–4.

如果您像我一样,并且只是在与Sagemaker玩耍而已,并且您不太在乎权限(因为所存储的信息都不是敏感的),则只需在第2–4页单击“下一步” 。

When you’re done, you should have a new S3 bucket! Now click your S3 bucket name.

完成后,您应该有一个新的S3存储桶! 现在,单击您的S3存储桶名称。

That should take you into your S3 bucket where you can upload data! Click ‘Upload’, then ‘Add Data’ and select your data from your local machine, and follow the prompts. Again, I don’t really care about permissions too much, so I just clicked ‘Next’ a lot after selecting my data.

那应该带您进入S3存储桶,您可以在其中上传数据! 单击“上传”,然后单击“添加数据”,然后从本地计算机中选择数据,然后按照提示进行操作。 同样,我不太在乎权限,因此选择数据后,我只是单击了“下一步”。

Note: there is a cost to S3. So you probably want to delete your data set and maybe even your bucket when you’re done.

注意:S3需要付费。 因此,您可能想要在完成后删除数据集,甚至删除存储桶。

步骤3:启动Sagemaker笔记本 (Step 3: Kick off a Sagemaker Notebook)

Go back to ‘Services’ and find \ click ‘Sagemaker’.

返回“服务”并找到\单击“ Sagemaker”。

Note: we’re going to kick off a notebook instance running on an ml.p2.xlarge which has a GPU and costs roughly $1.20/hr.

注意:我们将启动在ml.p2.xlarge上运行的笔记本实例,该实例具有GPU,每小时费用约为1.20美元。

https://aws.amazon.com/sagemaker/pricing/

https://aws.amazon.com/sagemaker/pricing/

When you’re done training, make sure to shut down the notebook instance. Also note that this job IS GOING TO COST YOU MONEY!!

完成培训后,请确保关闭笔记本实例。 另请注意,这项工作将花费您金钱!!

Click Notebook Instances > ‘Create Notebook Instance’

单击笔记本实例>“创建笔记本实例”

Now we’re going to give the notebook a name and make sure to select a ml.p2.xlarge to get a GPU instance.

现在,我们要给笔记本起个名字,并确保选择ml.p2.xlarge来获取GPU实例。

You might have to work through some permissions, and if you’re like me, you can bypass a lot of this. (I’m not going to cover any of this here). Also if you’re like me, you might have some issues getting access to a GPU, in which case just contact support via the ‘Support’ drop-down, and submit a quota increase to allow you to spin up GPU instances. If you require a quota increase, and your quota increase has been completed by AWS, you’ll have to go back to ‘Create Notebook Instance’ and start over.

您可能需要处理一些权限,如果您像我一样,可以绕开很多权限。 (我不会在这里讨论任何内容) 。 另外,如果您像我一样,在访问GPU时可能会遇到一些问题,在这种情况下,只需通过“支持”下拉菜单与支持人员联系,然后提交配额增加以允许您启动GPU实例。 如果您需要增加配额,并且AWS已经完成了配额增加,则必须回到“创建笔记本实例”并重新开始。

Once you’ve completed the ‘Create Notebook Instance’ steps, the notebook instance will now be created. This might take some time…

完成“创建笔记本实例”步骤后,现在将创建笔记本实例。 这可能需要一些时间...

Image for post
Photo by Mike Kenneally on Unsplash
Mike KenneallyUnsplash拍摄的照片

Once the instance is created, you should be able to click ‘Open Jupyter’ which will take you to Jupyter running on your new GPU instance\machine!

创建实例后,您应该可以单击“打开Jupyter”,这将带您在新的GPU实例\计算机上运行的Jupyter!

Once Jupyter is open, create a new ‘conda_tensorflow_36′ notebook by clicking the ‘New’ dropdown and selecting ‘conda_tensorflow_36′.

打开Jupyter后,通过单击“新建”下拉列表并选择“ conda_tensorflow_36”来创建一个新的“ conda_tensorflow_36”笔记本。

第4步:运行一些代码! (Step 4: Run some code!)

Now you can check out my full notebook on GitHub which includes comments to figure out how to connect to your data, install hyperopt, and run your job! See full GitHub repo with notebook here.

现在,您可以在GitHub上查看我的完整笔记本,其中包含注释,以弄清楚如何连接到数据,安装hyperopt以及运行您的工作! 在此处查看带有笔记本的完整GitHub存储库。

步骤5:全部关闭! (Step 5: Shut it all down!)

When you’re done, remember to shut down your notebook instance by clicking on your notebook instance name and then clicking ‘Stop’. I would even recommend deleting the notebook instance, as well as revisiting your S3 bucket and deleting your bucket, otherwise leaving all of this work sitting on Amazon WILL COST YOU MONEY!

完成后,请记住通过单击笔记本实例名称然后单击“停止”来关闭笔记本实例。 我什至建议您删除笔记本实例,以及重新访问S3存储桶并删除存储桶,否则,所有这些工作都将留在亚马逊上,这将使您大亏!

结束! (The End!)

Thanks, everyone and hope you found this helpful. Happy learning! :-D

谢谢大家,希望对您有所帮助。 学习愉快! :-D

其他资源\参考: (Other Resources \ References:)

https://github.com/hyperopt/hyperopt

https://github.com/hyperopt/hyperopt

https://hyperopt.github.io/hyperopt/

https://hyperopt.github.io/hyperopt/

https://scikit-learn.org/stable/modules/generated/sklearn.model_selection.RandomizedSearchCV.html

https://scikit-learn.org/stable/modules/generation/sklearn.model_selection.RandomizedSearchCV.html

https://aws.amazon.com/

https://aws.amazon.com/

https://blog.cloudability.com/aws-s3-understanding-cloud-storage-costs-to-save/

https://blog.cloudability.com/aws-s3-understanding-cloud-storage-costs-to-save/

https://github.com/yeamusic21/Hyperopt_On_Sagemaker/blob/master/Hyperas_mjy_v1_3.ipynb

https://github.com/yeamusic21/Hyperopt_On_Sagemaker/blob/master/Hyperas_mjy_v1_3.ipynb

翻译自: https://towardsdatascience.com/a-very-simple-introduction-to-deep-learning-on-amazon-sagemaker-b6ca2426275a

亚马逊深度学习库

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值