Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add ConvNet tutorials #2337

Merged
merged 12 commits into from Apr 21, 2017
Merged

Add ConvNet tutorials #2337

merged 12 commits into from Apr 21, 2017

Conversation

mitmul
Copy link
Member

@mitmul mitmul commented Feb 27, 2017

  • Convolutional Network for Visual Recognition Tasks
    • How to write a convolutional network that has a large number of components (ResNet)

@mitmul mitmul added cat:document Documentation such as function documentations, comments and tutorials. reviewer-team labels Mar 8, 2017
@mitmul mitmul changed the title [WIP] Add ConvNet tutorials Add ConvNet tutorials Apr 18, 2017
@bkvogel bkvogel self-assigned this Apr 18, 2017
Copy link
Contributor

@bkvogel bkvogel left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the tutorial! I think the content looks good, so I have only suggested some grammatical and wording changes.

I also wonder if it could be useful for one of the examples to use the parameter shape placeholder feature so that users can know about it, but I don't think it is required. You can decide.


After reading this section, you will be able to:

* Write your original convolutional network in Chainer
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consider rewording:

Write your own original convolutional network in Chainer

* Write your original convolutional network in Chainer

A convolutional network (ConvNet) is mainly comprised of convolutional layers.
This type of network is oftenly used for various visual recognition tasks,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This type of network is commonly used for

- :math:`H` and :math:`W` denote the height and width of those images,

respectively. Then, it typically outputs a fixed-sized vector as membership
probability over the target object classes. It also can output a set of feature
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Then, it typically outputs a fixed-sized vector of membership probabilities over the target object classes.

LeNet5
''''''

Here, let's start from defining LeNet5 [LeCun98]_ in Chainer.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here, let's start by defining LeNet5 [LeCun98]_ in Chainer.


Here, let's start from defining LeNet5 [LeCun98]_ in Chainer.
This is a ConvNet model that has 5 layers comprised of 3 convolutional layers
and 2 fully-connected layers. This has been proposed to classify hand-written
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was proposed

In :class:`BottleNeck` class, it switches whther ``conv1x1r`` to fit the
channel dimension of the input ``x`` and the output ``h`` and ``bn_r`` for it
should be added or not with respect to :attr:`~BottleNeck.proj` attribute.
Writing the building block in this way gains the re-usability of a class a lot.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In the :class:BottleNeck class, depending on the value of the proj argument supplied to the initializer, it will conditionally also compute the batch normalization of a conv1x1r layer before the final ReLU layer. Writing the building block in this way improves the re-usability of a class.

Copy link
Member Author

@mitmul mitmul Apr 21, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@bkvogel Thank you for great re-wording! In this sentence, I'd like to say the computation of conv1x1r itself is also conditional. So can I say as the below? :

it will conditionally compute a convolutional layer conv1x1r and the following batch normalization layer before the final ReLU layer

I'd appreciate it if you could check this part again :)

Copy link
Member Author

@mitmul mitmul Apr 21, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry, additionally, I'd like to say the conv1x1r is used to make the number of channels of the input x same as the number of channels of the output of conv1x1c. This part "conv1x1r to fit the channel dimension of the input x and the output h" intended to say that. Could you advise me how to add this information to this paragraph? How about this?:

it will conditionally compute a convolutional layer conv1x1r which is to make the number of channels of the input x same as the number of channels of the output of conv1x1c, and the following batch normalization layer before the final ReLU layer.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How about:

it will conditionally compute a convolutional layer conv1x1r which will extend the number of channels of the input x to be equal to the number of channels of the output of conv1x1c, and followed by a batch normalization layer before the final ReLU layer.

usage would be efficient compared to the case when it registers both anyway and
just ignore them if :attr:`proj` is ``False``.

Using nesting :class:`~chainer.Chain` s and :class:`~chainer.ChainList` for
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Using nested

very useful as general feature extractor for many different tasks from image
classification. So Chainer provides you the pre-trained models of VGG16 and
ResNet-50/101/152 models with a simple API. You can use those models in this
way:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Various ways to write your models were described above. It turns out that VGG16 and ResNet are very useful as general feature extractors for many different image classification tasks. So, Chainer provides you with the pre-trained VGG16 and ResNet-50/101/152 models with a simple API. You can use these models as follows:

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry, I intended to say "those models are useful not only for classification tasks but also for many different tasks other than classification tasks". So can I say this as follows?:

It turns out that VGG16 and ResNet are very useful as general feature extractors noy only for image classification tasks but also for many different tasks other than classification.

I'd appreciate it if you could check this part again :)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How about:

Various ways to write your models were described above. It turns out that VGG16 and ResNet are very useful as general feature extractors for many kinds of tasks, including but not limited to image classification. So, Chainer provides you with the pre-trained VGG16 and ResNet-50/101/152 models with a simple API. You can use these models as follows:

model = VGG16Layers()

When :class:`~chainer.links.VGG16Layers` is instantiated, the pre-trained
parameters is automatically downloaded from the author's server. So you can
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the pre-trained parameters are automatically downloaded

:class:`chainer.links.VGG16Layers`.

In the case of ResNet models, there are 3 variation in terms of the number of
layers. We have :class:`chainer.links.ResNet50`,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In the case of ResNet models, there are three variations differing in the number of layers.

@mitmul
Copy link
Member Author

mitmul commented Apr 21, 2017

@bkvogel Thank you for reviewing! I'd like to confirm two points replied in the above comments. I'd appreciate it if you could check them again :)

def __call__(self, x, train):
h = F.relu(self.bn_a(self.conv1x1a(x), test=not train))
h = F.relu(self.bn_b(self.conv3x3b(x), test=not train))
h = self.bn_c(self.conv1x1c(x), test=not train)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this code correct? It looks like you keep overwriting h because the value is not used in the following lines (it keeps reading from x only).

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry, this code is wrong. I'll fix it. Thank you for pointing out it!

@mitmul
Copy link
Member Author

mitmul commented Apr 21, 2017

Thank you for replying my comments. I fixed all points by following your suggestions :)

@bkvogel
Copy link
Contributor

bkvogel commented Apr 21, 2017

LGTM!

@bkvogel bkvogel merged commit 71fc7b8 into master Apr 21, 2017
@bkvogel bkvogel deleted the add-conv-tutorial branch April 21, 2017 10:09
@beam2d beam2d added this to the v1.24.0 milestone May 11, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cat:document Documentation such as function documentations, comments and tutorials.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants