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
Add ConvNet tutorials #2337
Conversation
mitmul
commented
Feb 27, 2017
•
edited
edited
- Convolutional Network for Visual Recognition Tasks
- How to write a convolutional network that has a large number of components (ResNet)
There was a problem hiding this 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.
docs/source/tutorial/convnet.rst
Outdated
|
||
After reading this section, you will be able to: | ||
|
||
* Write your original convolutional network in Chainer |
There was a problem hiding this comment.
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
docs/source/tutorial/convnet.rst
Outdated
* 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, |
There was a problem hiding this comment.
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
docs/source/tutorial/convnet.rst
Outdated
- :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 |
There was a problem hiding this comment.
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.
docs/source/tutorial/convnet.rst
Outdated
LeNet5 | ||
'''''' | ||
|
||
Here, let's start from defining LeNet5 [LeCun98]_ in Chainer. |
There was a problem hiding this comment.
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.
docs/source/tutorial/convnet.rst
Outdated
|
||
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 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This was proposed
docs/source/tutorial/convnet.rst
Outdated
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. |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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 :)
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
docs/source/tutorial/convnet.rst
Outdated
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 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Using nested
docs/source/tutorial/convnet.rst
Outdated
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: |
There was a problem hiding this comment.
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:
There was a problem hiding this comment.
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 :)
There was a problem hiding this comment.
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:
docs/source/tutorial/convnet.rst
Outdated
model = VGG16Layers() | ||
|
||
When :class:`~chainer.links.VGG16Layers` is instantiated, the pre-trained | ||
parameters is automatically downloaded from the author's server. So you can |
There was a problem hiding this comment.
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
docs/source/tutorial/convnet.rst
Outdated
: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`, |
There was a problem hiding this comment.
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.
@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 :) |
docs/source/tutorial/convnet.rst
Outdated
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) |
There was a problem hiding this comment.
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).
There was a problem hiding this comment.
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!
Thank you for replying my comments. I fixed all points by following your suggestions :) |
LGTM! |