keras构建卷积神经网络_通过此简单教程学习在网络上构建卷积神经网络

keras构建卷积神经网络

by John David Chibuk

约翰·大卫·奇布克(John David Chibuk)

通过此简单教程学习在网络上构建卷积神经网络 (Learn to build a Convolutional Neural Network on the web with this easy tutorial)

This post explains how to build your first Convolutional Neural Network (CNN) to detect between two image types: for example, a bunny or a puppy.

这篇文章介绍了如何构建您的第一个卷积神经网络(CNN),以在两种图像类型之间进行检测:例如,兔子或小狗。

Thanks to Google’s new web tool, getting started building and prototyping your own neural network can be quite easy.

借助Google的新网络工具,您可以很轻松地开始构建自己的神经网络并进行原型设计。

Here is a link to the web-based application. It shows you the code and lets you run “paragraph by paragraph” (shift+enter) jupyter notebook code to let you train a model and then test it. Find the Github public repo here.

这是基于Web的应用程序的链接 。 它 向您显示代码,并让您运行“逐段”( shift + enter )jupyter笔记本代码,以训练模型然后进行测试。 在此处找到Github公共仓库

The first step is to set up the Colab notebook + image data folders on your own Google drive, so let’s do that!

第一步是在您自己的Google驱动器上设置Colab笔记本+图像数据文件夹,让我们开始吧!

In your Google drive, you will need to set up folders with images that store the data to be trained. You can copy this folder directly and put in your own Google drive, and then unzip it and put it in a folder called “Colab Notebooks” in your base Google drive folder.

在您的Google云端硬盘中,您需要设置包含图像的文件夹,这些图像存储了要训练的数据。 您可以直接复制此文件夹并放入您自己的Google驱动器中,然后将其解压缩并放入基本Google驱动器文件夹中名为“ Colab Notebooks”的文件夹中。

In the images folder, there are two subfolders.

在images文件夹中,有两个子文件夹。

train
培养
test
测试

Each of these folders then contains folders to represent the types of images you want to identify.

这些文件夹中的每一个都包含代表您要识别的图像类型的文件夹。

bunny
兔子
puppy
小狗

There should be a bunny and puppy folder in each train + test folder.

每个火车+测试文件夹中应该有一个兔子和小狗文件夹。

Fill these folders with images. Put ~80% in the train folder and 20% in the test folder.

用图像填充这些文件夹。 将约80%放置在训练文件夹中,并将20%放置在测试文件夹中。

The tricky part of the tutorial is getting the folders linked properly within Google drive. You need to connect via API keys a few times to establish the proper connection to your personal Google drive folder.

本教程的棘手部分是将文件夹正确链接到Google驱动器中。 您需要通过API密钥连接几次,以建立与您的个人Google驱动器文件夹的正确连接。

Please note: you need to keep the same folder structure as defined in the tutorial to have it run properly.

请注意:您需要保持与教程中定义的文件夹结构相同的文件夹结构,以使其正常运行。

In your base Google Drive folder, you should have a folder called: Colab Notebooks.

在基本的Google云端硬盘文件夹中,您应该有一个名为Colab笔记本的文件夹。

Inside there should be a directory called: Simple CNN Image Tutorial

里面应该有一个目录:Simple CNN Image Tutorial

This should contain the contents of the images and Colab notebook from above.

这应该包含上面图像和Colab笔记本的内容。

一步步 (Step by step)

Step 1 installs the required libraries to build and train a model with Google’s tensorflow + Keras. Keras is a simplified layer to make model training easier on top of Tensorflow.

第1步安装所需的库,以使用Google的tensorflow + Keras构建和训练模型。 Keras是一个简化的层,可以使在Tensorflow之上的模型训练更加容易。

Step 2–5 links your Google drive up to the project, copies the keys over from the cells, and pastes them in the notebook as they are generated. This might take a few tries, but its okay!

第2-5步将您的Google驱动器链接到项目,从单元格复制密钥,然后将其粘贴到笔记本中。 这可能需要几次尝试,但是还可以!

Step 6 You can change the structure, but you will need to update the path in the notebook to match where you put the base Simple CNN Image Tutorial folder.

步骤6您可以更改结构,但需要更新笔记本中的路径以匹配放置“基本CNN图像教程”文件夹的位置。

Step 7 confirms that you have your images loaded in Google drive.

步骤7确认您已将图像加载到Google驱动器中。

To run the process, simply click the first paragraph area and click “shift + enter” on your keyboard. This runs the code in each cell and lets you step through the process.

要运行该过程,只需单击第一段区域,然后在键盘上单击“ Shift + Enter”。 这将在每个单元格中运行代码,并让您逐步完成该过程。

Step 9 trains your model. If everything is referenced properly it should show output like this ->

第9步训练您的模型。 如果正确引用了所有内容,则应显示如下输出->

When it’s done, your model will be trained and you can test images from what you put in the new images folder:

完成后,将对模型进行训练,并且可以从新图像文件夹中放置的图像中测试图像:

Simply change the image name text in the line of code:

只需在代码行中更改图像名称文本:

test_image = image.load_img(‘./newimages/puppy3.jpg’, target_size = (64, 64))

So you would change for example:

因此,您将例如进行更改:

‘./newimages/puppy3.jpg’ to ‘./newimages/bunny1.jpg’

Finally run the paragraph and see what your model classifies the new image to be!

最后运行该段落,看看您的模型将新图像分类为什么!

恭喜,您刚刚训练和测试了您的第一个卷积神经网络-香蕉! (Congrats you have just trained and tested your first convolutional neural network — it’s bananas!)

翻译自: https://www.freecodecamp.org/news/learn-to-build-a-convolutional-neural-network-on-the-web-with-this-easy-tutorial-2d617ffeaef3/

keras构建卷积神经网络

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值