Step by Step Implementation: 3D Convolutional Neural Network in Keras

栏目: IT技术 · 发布时间: 5年前

内容简介:In this article, we will be briefly explaining what a 3d CNN is, and how it is different from a generic 2d CNN. Then we will teach you step by step how to implement your own 3D Convolutional Neural Network using Keras.A 3d CNN remains regardless of what we
Learn how to implement your very own 3D CNN

In this article, we will be briefly explaining what a 3d CNN is, and how it is different from a generic 2d CNN. Then we will teach you step by step how to implement your own 3D Convolutional Neural Network using Keras.

1] What is a 3D Convolutional Neural Network?

A 3d CNN remains regardless of what we say a CNN that is very much similar to 2d CNN. Except that it differs in these following points (non-exhaustive listing):

3d Convolution Layers

Originally a 2d Convolution Layer is an entry per entry multiplication between the input and the different filters, where filters and inputs are 2d matrices. (fig.1)

Step by Step Implementation: 3D Convolutional Neural Network in Keras

fig.1 (copyrighted: own)

In a 3d Convolution Layer, the same operations are used. We do these operations on multiple pairs of 2d matrices. (fig.2)

Step by Step Implementation: 3D Convolutional Neural Network in Keras

fig.2 (copyrighted: own)

Padding options and slides step options work the same way.

3d MaxPool Layers

2d Maxpool Layers (2x2 filter) is about taking the maximum element of a small 2x2 square that we delimitate from the input. (fig.3)

Step by Step Implementation: 3D Convolutional Neural Network in Keras

fig.3(copyrighted: own)

Now in a 3d Maxpool (2x2x2), we look for the maximum element in a width 2 cube. This cube represents the space delimited by the 2x2x2 zone from the input. (fig.4)

Step by Step Implementation: 3D Convolutional Neural Network in Keras

fig.4(copyrighted: own)

Note that the number of operations (compared to 2d CNN layers) is multiplied by the size of the filters used (regardless of the layer being Maxpool or Convolution) and also multiplied by the size of the input itself.

2] 3d existing Datasets

So how does a data point for a 3d CNN look like?

One way to picture it is by using the following image (fig.5):

Step by Step Implementation: 3D Convolutional Neural Network in Keras

fig.5 (copyrighted: own)

Other existing datasets that you can use for your CNN are:

3] Preprocessing and Implementations

You can try for yourself the code on this dataset from Kaggle that we are using.

The required libraries to import are as follows:

To begin with, since the dataset is a bit specific, we use the following to helper functions to process them before giving them to the network.

Plus, the dataset is stored as h5 file, so to extract the actual data points, we are required to read from h5 file, and use the to_categorical function to transform it into vectors. In this step, we also prepare for cross-validation.

Finally, the model and the syntax for 3d CNN are as follows: (the architecture was picked without much refining since that is not the point of this article)

Note that the numbers of parameters will be a lot higher for the same number of layers compared to 2d CNN.

For your information, after a small sample training, we got the following accuracies and losses. (fig.6)

Step by Step Implementation: 3D Convolutional Neural Network in Keras

fig.6 (copyrighted: own)

4] But then a 3d? What for?

There happens to have many applications for a 3d CNN that are for instance:

  • IRM data processing and therefore the inference
  • self-driving
  • Distance estimation

Alright, that’s pretty much all. I hope you will try this technology out!


以上就是本文的全部内容,希望本文的内容对大家的学习或者工作能带来一定的帮助,也希望大家多多支持 码农网

查看所有标签

猜你喜欢:

本站部分资源来源于网络,本站转载出于传递更多信息之目的,版权归原作者或者来源机构所有,如转载稿涉及版权问题,请联系我们

与机器赛跑

与机器赛跑

[美]埃里克·布林约尔松(Erik Brynjolfsson)、[美]安德鲁·麦卡菲(Andrew McAfee) / 闾佳 / 2013-1-20 / 6.00

一场数字革命正在加速进行。 一些科幻小说里的场景已经在现实中发生:无人驾驶汽车开上了公路;智能设备能高效地翻译人类语言;人工智能系统在智力竞赛里击败了所有人类选手;工厂雇主开始购买更多的新机器,却不招新工人…… 这些例子都证明,数字技术正在快速地掌握原本只属于人类的技能,并深刻地影响了经济。虽然大多数影响是积极的:数字革新将提高效率、降低商品价格(甚至到免费),以及增加经济总量。 ......一起来看看 《与机器赛跑》 这本书的介绍吧!

HTML 压缩/解压工具
HTML 压缩/解压工具

在线压缩/解压 HTML 代码

MD5 加密
MD5 加密

MD5 加密工具

UNIX 时间戳转换
UNIX 时间戳转换

UNIX 时间戳转换