Skip to content
This repository was archived by the owner on Oct 17, 2021. It is now read-only.

Add maxPooling3d layer & averagePooling3d layer #555

Merged
merged 8 commits into from
Aug 15, 2019

Conversation

syt123450
Copy link
Contributor

@syt123450 syt123450 commented Jun 6, 2019

This PR adds averagePooling3d layer & maxPooling3d layer(feature requested in tensorflow/tfjs#1035).

Features in this PR:

  • Add pool3d function to compute 3D pooling
  • Add relative tests for pool3d function
  • Add Pooling3DLayerArgs interface
  • Add abstract Pooling3D class
  • Add MaxPooling3D class
  • Add AveragePooling3D class
  • Export averagePooling3d layer
  • Add relative tests for averagePooling3d layer
  • Export maxPooling3d layer
  • Add relative tests for maxPooling3d layer

Note:

This PR depends on PR tensorflow/tfjs-core#1778, which adds maxPool3d op, avgPool3d op, and exports Tensor5D type.

Reference:


To see the logs from the Cloud Build CI, please join either our discussion or announcement mailing list.


This change is Reviewable

dsmilkov pushed a commit to tensorflow/tfjs-core that referenced this pull request Aug 8, 2019
This PR adds `avgPool3d` op & `maxPool3d` op with CPU and WebGL implementation, supports inference and gradient. The APIs align with TensorFlow’s Python API [tf.nn.avg_pool3d](https://www.tensorflow.org/versions/r2.0/api_docs/python/tf/nn/avg_pool3d) and [tf.nn.max_pool3d](https://www.tensorflow.org/versions/r2.0/api_docs/python/tf/nn/max_pool3d). The `avgPool3d` & `maxPool3d` ops support `tf.layers.averagePooling3d` & `tf.layers.maxPooling3d` (feature requested in [tensorflow/tfjs#1035](tensorflow/tfjs#1035)).

As a checklist, features in this PR:
* Add `tf.avgPool3d` to ops
* Add `tf.maxPool3d` to ops
* Add `avgPool3d` kernel to handle `tf.avgPool3d`’s prediction
* Add `maxPool3d` kernel to handle `tf.maxPool3d`’s prediction
* Add private helper `pool3d` function in CPU kernel as the implementation of `avgPool3d` kernel and `maxPool3d` kernel in CPU end
* Add `Pool3DProgram` in WebGL kernel as the implementation of `avgPool3d` kernel and `maxPool3d` kernel in GPU end
* Add `avgPool3dBackprop` kernel to handle `tf.avgPool3d`’s gradient
* Add `avgPool3dBackprop` CPU kernel implementation
* Add `AvgPool3DBackpropProgram` as the implementation of `avgPool3dBackprop` WebGL kernel
* Add `maxPool3dBackprop` kernel to handle `tf.maxPool3d`’s gradient
* Add `maxPool3dBackprop` CPU kernel implementation
* Add a private helper function `maxPool3dPositions` for maxPool3dBackprop in CPU kernel
* Add `MaxPool3DBackpropProgram` as the implementation of `maxPool3dBackprop` WebGL kernel
* Integrate WebGL end’s `maxPool3dPositions` helper function into Pool3DProgram
* Add a `computePool3DInfo` util function to compute operation information for `avgPool3d` & `maxPool3d`
* Make check function `eitherStridesOrDilationsAreOne` support 3D input
* Add 14 unit tests for `avgPool3d` (one test case failed in nodejs env as TF Backend doesn’t support `NUMBER` pad mode)
* Add 7 unit tests for `avgPool3dBackprop`
* Add 13 unit tests for `maxPool3d` (one test case failed in nodejs env as TF Backend doesn’t support `NUMBER` pad mode)
* Add 10 unit tests for `maxPool3dBackprop`
* Add 8 unit tests for util function `computePool3DInfo`
* Export `Tensor5D `type
* Add jsdocs and executable examples for website api documentation

I built a local website, if everything goes well, the `avgPool3d` and `maxPool3d` APIs would lie in `Operations/Convolution` section and look like the screen shot below:
<img width="1184" alt="Screen Shot 2019-06-06 at 1 32 30 AM" src="https://user-images.githubusercontent.com/7977100/59018883-c13c3400-87fb-11e9-8f36-316edab35231.png">

**Relative PRs:**
* Make nodejs kernel support  avgPool3d & maxPool3d  [tensorflow/tfjs-node#256](tensorflow/tfjs-node#256)
* Add averagePooling3d layer & maxPooling3d layer [tensorflow/tfjs-layers#555](tensorflow/tfjs-layers#555)
* Add avgPool3d & maxPool3d ops for graph model [tensorflow/tfjs-converter#375](tensorflow/tfjs-converter#375)

**Reference:**
* [tf.nn.avg_pool3d TensorFlow Python API](https://www.tensorflow.org/versions/r2.0/api_docs/python/tf/nn/avg_pool3d)
* [tf.nn.max_pool3d TensorFlow Python API](https://www.tensorflow.org/versions/r2.0/api_docs/python/tf/nn/max_pool3d)
---
To see the logs from the Cloud Build CI, please join either
our [discussion](https://groups.google.com/a/tensorflow.org/forum/#!forum/tfjs)
or [announcement](https://groups.google.com/a/tensorflow.org/forum/#!forum/tfjs-announce) mailing list.

FEATURE
Copy link
Contributor

@caisq caisq left a comment

Choose a reason for hiding this comment

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

Thanks, @syt123450

Will merge as soon as the tests pass.

@caisq caisq merged commit 8c2e26c into tensorflow:master Aug 15, 2019
@syt123450
Copy link
Contributor Author

Thanks for the review @caisq !

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants