Skip to content

Comments

API Redesign#2229

Merged
lmoneta merged 4 commits intoroot-project:masterfrom
steremma:redesign-api
Jun 27, 2018
Merged

API Redesign#2229
lmoneta merged 4 commits intoroot-project:masterfrom
steremma:redesign-api

Conversation

@steremma
Copy link
Contributor

API Redesign

Goal

The goal is this PR is to improve the API of the CNN layers (MaxPooling and Conv currently), by eliminating redundant constructor arguments and fields. By redundant in this context, I refer to arguments that can be directly computed from others, and fields that unnecesseraly exist in multiple classes.

Key points

Below some discussion points on design decisions I made, but still consider debatable.
Since my experience in production level C++ is very limited I highly value opinions from experienced colleagues and previous authors of the module.

Making MaxPoolingLayer a sub-class of ConvLayer

Every layer type in a convolutional network follows the logic existing in our ConvLayer:

A filter is sliding over the input and at each step applies an operation to the input elements within its receptive field to produce a single output element.

  • In a convolutional layer this operation is a linear combination with learnable parameters.
  • In an average pooling layer the operation is a linear combination with constant parameters (and equal to the inverse of the receptive field's size).
  • In a max pooling layer its a non linear operation.

As we can see they all share the same logic and therefore fields.

Results

  1. Common fields between the 2 layer types in the CNN module are now not duplicated (strides sizes, padding sizes, filter sizes). The same for the 4 protected methods in ConvLayer.

  2. We now have a cleaner API, as the constructor arguments where reduced from 26 to 16 without any change in the functionality).

steremma added 4 commits June 22, 2018 17:13
…MaxPoolingLayer`

* Pooling is now a subclass of Convolutional Layer. As a result common functions and fields are not replicated.
* Constructor arguments that can be internally computed are eliminated.
…frame". This is important to have the same naming convention everywhere.
@steremma steremma requested a review from lmoneta as a code owner June 23, 2018 10:38
@phsft-bot
Copy link

Can one of the admins verify this patch?

@steremma steremma mentioned this pull request Jun 23, 2018
@lmoneta lmoneta merged commit 0a7faec into root-project:master Jun 27, 2018
steremma added a commit to steremma/root that referenced this pull request Jun 28, 2018
lmoneta pushed a commit that referenced this pull request Jun 28, 2018
steremma added a commit to steremma/root that referenced this pull request Jun 28, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants