Skip to content
This repository was archived by the owner on Jul 10, 2025. It is now read-only.

Commit ef62689

Browse files
seanpmorganewilderj
authored andcommitted
RFC: Move from tf.contrib to addons (#37)
* Checkpoint addons RFC for review * Add code review to RFC Add future pull request information to criteria Update modified date added some description RFC Move to addons * Add weight decay optimizers * Remove conv2d_in_plane * Add group_norm * Accept addons RFC
1 parent 0512aeb commit ef62689

File tree

1 file changed

+231
-0
lines changed

1 file changed

+231
-0
lines changed

rfcs/20181214-move-to-addons.md

Lines changed: 231 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,231 @@
1+
# Move from tf.contrib to tensorflow/addons
2+
3+
| Status | Accepted |
4+
:-------------- |:---------------------------------------------------- |
5+
| **Author(s)** | Sean Morgan ([email protected]), Armando Fandango ([email protected]) |
6+
| **Sponsor** | Karmel Allison ([email protected]) |
7+
| **Updated** | 2018-12-16 |
8+
9+
## Objective
10+
11+
With the upcoming removal of tf.contrib in TF 2.0, we are in the process
12+
of deciding what existing functionality will be moved and maintained in
13+
the [tensorflow/addons](https://github.com/tensorflow/addons)
14+
repository.
15+
16+
This document details what functionality the SIG plans to move and
17+
invites discussion around the decisions.
18+
19+
20+
## Motivation
21+
22+
In this RFC, we are soliciting discussion regarding what tf.contrib code
23+
should be moved to tensorflow/addons. This RFC discussion will help us
24+
determine the value of moving code and their respective
25+
maintainability aspects.
26+
27+
## Design Proposal
28+
29+
### Criteria for moving
30+
1) The functionality is not otherwise available in TensorFlow
31+
1) There is sufficient interest in the community to maintain the code being moved
32+
1) The code conforms to an established API pattern (Some pieces can be refactored if needed)
33+
34+
It is worth noting that just because some functionality isn't part of
35+
the initial move, does not mean it won't be eventually part of addons
36+
if there is value. We will begin reviewing pull requests to the
37+
repository after the directory structure is shaped during the initial move.
38+
39+
### Code to be moved from tf.contrib to addons
40+
41+
| Module (tf.contrib) | Class/Function | Rationale |
42+
|:----------------------- |:----------- |:------------------------------------ |
43+
| opt.external_optimizer | ExternalOptimizerInferface | Base class for external optimizers used in OSS projects |
44+
| opt.external_optimizer | ScipyOptimizerInterface | Significant usage in OSS projects |
45+
| opt.lazy_adam_optimizer | LazyAdamOptimizer | Significant usage in OSS projects / discussions |
46+
| opt.moving_average_optimizer | MovingAverageOptimizer | Significant usage in OSS projects |
47+
| layers.layers | dense_to_sparse | Useful functionality and discussion around it |
48+
| layers.layers | layer_norm | Heavily used is OSS projects / From impactful paper |
49+
| layers.layers | maxout | From impactful paper |
50+
| layers.layers | poincare_normalize | Functionality not available / Useful for hyperbolic embeddings |
51+
| layers.normalization | instance_norm | Heavily used is OSS projects / Used for style xfer |
52+
| layers.normalization | group_norm | Will be moved as a generalized case of layer_norm and instance_norm |
53+
| losses.metric_loss_ops | pairwise_distance | Useful functionality not otherwise available |
54+
| losses.metric_loss_ops | contrastive_loss | Useful functionality not otherwise available |
55+
| losses.metric_loss_ops | masked_maximum | Useful functionality not otherwise available |
56+
| losses.metric_loss_ops | masked_minimum | Useful functionality not otherwise available |
57+
| losses.metric_loss_ops | triplet_semihard_loss | Useful functionality not otherwise available / From impactful paper |
58+
| losses.metric_loss_ops | npairs_loss | Useful functionality not otherwise available |
59+
| losses.metric_loss_ops | npairs_loss_multilabel | Useful functionality not otherwise available |
60+
| losses.metric_loss_ops | lifted_struct_loss | Useful functionality not otherwise available |
61+
| sparsemax.sparsemax | ALL | Useful functionality not otherwise available / Volunteers to maintain |
62+
| image.dense_image_warp | dense_image_warp | Useful functionality not otherwise available |
63+
| image.distort_image_ops | random_hsv_in_yiq | Useful functionality not otherwise available |
64+
| image.distort_image_ops | adjust_hsv_in_yiq | Useful functionality not otherwise available |
65+
| image.image_ops | rotate | Useful functionality not otherwise available / Several uses in OSS found |
66+
| image.image_ops | translate | Useful functionality not otherwise available |
67+
| image.image_ops | angles_to_projective_transforms | Useful functionality not otherwise available / Several uses in OSS found |
68+
| image.image_ops | translations_to_projective_transforms | Useful functionality not otherwise available |
69+
| image.image_ops | transform | Useful functionality not otherwise available / Several uses in OSS found |
70+
| image.image_ops | compose_transforms | Useful functionality not otherwise available / Several uses in OSS found |
71+
| image.image_ops | flat_transforms_to_matrices | Helper util used a few times in module |
72+
| image.image_ops | matrices_to_flat_transforms | Helper util used a few times in module |
73+
| image.image_ops | connected_components | Useful functionality not otherwise available |
74+
| text.skip_gram_ops | ALL | Useful functionality not otherwise available |
75+
| crf.crf | ALL | Heavily used by the NLP community |
76+
| opt.weight_decay_optimizers | DecoupledWeightDecayExtension | ~SOTA convergence speeds / Needs refactored as Wrapper subclass |
77+
| opt.weight_decay_optimizers | AdamWOptimizer | ~SOTA convergence speeds / Needs refactored as wrapper + keras Adam |
78+
| opt.weight_decay_optimizers | MomentumWOptimizer | ~SOTA convergence speeds / Needs refactored as wrapper + keras SGD|
79+
80+
### Code that will not be moved from tf.contrib pending objections
81+
82+
| Module (tf.contrib) | Class/Function | Rationale |
83+
|:----------------------- |:----------- |:------------------------------------ |
84+
| opt.addsign | AddSignOptimizer | No OSS uses found / Needs refactored as OptimizerV2 subclass |
85+
| opt.agn_optimizer | AGNOptimizer | No OSS uses found / Needs refactored as OptimizerV2 subclass |
86+
| opt.drop_stale_gradient_optimizer | DropStaleGradientOptimizer | No OSS uses found / Needs refactored as Wrapper subclass |
87+
| opt.elastic_average_optimizer | ElasticAverageOptimizer | No OSS uses found / Needs refactored as Wrapper subclass |
88+
| opt.ggt | GGTOptimizer | No OSS uses found |
89+
| opt.lars_optimizer | LARSOptimizer | No OSS uses found / Needs refactored as OptimizerV2 subclass |
90+
| opt.shampoo | ShampooOptimizer | No OSS uses found / Needs refactored as OptimizerV2 subclass |
91+
| opt.matrix_functions | matrix_inverse_pth_root | Used in opt.shampoo |
92+
| opt.model_average_optimizer | ModelAverageOptimizer | No OSS uses found / Needs refactored as Wrapper subclass |
93+
| opt.multitask_optimizer_wrapper | MultitaskOptimizerWrapper | No OSS uses found / Needs refactored as Wrapper subclass |
94+
| opt.multitask_optimizer_wrapper | clip_gradients_by_global_norm | No OSS uses found / Specific to MultitaskOptimizers / At least partly covered in Keras optimizer |
95+
| opt.powersign | PowerSignOptimizer | No OSS uses found / Needs refactored as OptimizerV2 subclass |
96+
| opt.sign_decay | get_linear_decay_fn | No OSS usage / Used in AddSign & PowerSign |
97+
| opt.sign_decay | get_cosine_decay_fn | No OSS usage / Not an optimizer |
98+
| opt.sign_decay | get_restart_decay_fn | No OSS usage / Not an optimizer |
99+
| opt.reg_adagrad_optimizer | RegAdagradOptimizer | No OSS uses found / Needs refactored as keraas Adagrad subclass |
100+
| opt.variable_clipping_optimizer | VariableClippingOptimizer | No OSS uses found / Needs refactored as Wrapper subclass / partial covered by keras norm clip |
101+
| opt.weight_decay_optimizers | ShampooWOptimizer | No OSS uses found |
102+
| opt.weight_decay_optimizers | extend_with_decoupled_weight_decay | No OSS uses found / Functional paradigm - factory function |
103+
| layers.embedding_ops | scattered_embedding_lookup_sparse | No OSS uses found |
104+
| layers.embedding_ops | embedding_lookup_unique | No OSS uses found |
105+
| layers.encoders | bow_encoder | Creates variables, but does not subclass Layer |
106+
| layers.encoders | embed_sequence | Creates variables, but does not subclass Layer |
107+
| layers.layers | convolution2d_in_plane | No OSS uses found |
108+
| layers.layers | GDN | No OSS uses found |
109+
| layers.layers | scale_gradient | No OSS uses found |
110+
| layers.layers | sequence_to_images | No OSS uses found |
111+
| layers.layers | spatial_softmax | One OSS project found / Needs refactored as base Layer subclass / Uses get_variable_collections |
112+
| layers.optimizers | optimize_loss | Concience wrapper to build a training op / Would need refactor to stick to TF2.0 APIs |
113+
| layers.optimizers | adaptive_clipping_fn | No OSS uses found |
114+
| layers.rev_block_lib | RevBlock | No OSS uses found |
115+
| layers.rev_block_lib | recompute_grad | No OSS uses found |
116+
| layers.summaries | summarize_tensor | One OSS project found / Very simple wrapper |
117+
| layers.utils | constant_value | Simple wrapper... need a good reason to support |
118+
| nn.alpha_dropout | alpha_dropout | No OSS uses found / Needs refactored as base Layer subclass |
119+
| nn.fwd_gradients | fwd_gradients | No OSS uses found |
120+
| nn.sampling_ops | rank_sampled_softmax_loss | One OSS use found / Needs to utilize sampled_softmax_loss_v2 |
121+
| nn.sampling_ops | sampled_sparse_softmax_loss | No OSS uses found / Needs to utilize sampled_softmax_loss_v2 |
122+
| nn.scaled_softplus | scaled_softplus | No OSS uses found |
123+
| losses.metric_loss_ops | update_1d_tensor | No OSS uses found / Large amount of code related to cluster_loss |
124+
| losses.metric_loss_ops | get_cluster_assignment | No OSS uses found / Large amount of code related to cluster_loss |
125+
| losses.metric_loss_ops | compute_facility_energy | No OSS uses found / Large amount of code related to cluster_loss |
126+
| losses.metric_loss_ops | compute_clustering_score | No OSS uses found / Large amount of code related to cluster_loss |
127+
| losses.metric_loss_ops | compute_augmented_facility_locations | No OSS uses found / Large amount of code related to cluster_loss |
128+
| losses.metric_loss_ops | update_medoid_per_cluster | No OSS uses found / Large amount of code related to cluster_loss |
129+
| losses.metric_loss_ops | update_all_medoids | No OSS uses found / Large amount of code related to cluster_loss |
130+
| losses.metric_loss_ops | compute_augmented_facility_locations_pam | No OSS uses found / Large amount of code related to cluster_loss |
131+
| losses.metric_loss_ops | compute_gt_cluster_score | No OSS uses found / Large amount of code related to cluster_loss |
132+
| losses.metric_loss_ops | cluster_loss | No OSS uses found / Large amount of code related to cluster_loss |
133+
| image.image_ops | bipartite_match | No OSS uses found / Should live in linalg or somewhere else? |
134+
| image.interpolate_spline | interpolate_spline | One OSS uses found / Should live in tf.signal? |
135+
| image.single_image_random_dot_stereograms | single_image_random_dot_stereograms | No OSS uses found |
136+
| image.parse_image_wrap | sparse_image_warp | No OSS uses found |
137+
| resampler.resampler_ops | ALL | Pending community interest |
138+
| solvers | ALL | Pending community interest to maintain |
139+
| integrate | ALL | Pending community interest to maintain |
140+
141+
### Code that will not be copied from tf.contrib to addons and hence would not be available in either of tf.contrib or addons
142+
143+
| Module (tf.contrib) | Class/Function | Rationale |
144+
|:----------------------- |:----------- |:------------------------------------ |
145+
| opt.adamax | AdaMaxOptimizer | Available in tf.keras.optimizers |
146+
| opt.matrix_functions | matrix_square_root | Available as linalg_ops.matrix_square_root |
147+
| opt.nadam_optimizer | NadamOptimizer | Available in tf.keras.optimizers |
148+
| layers.embedding_ops | safe_embedding_lookup_sparse | Exists as tf.nn.safe_embedding_lookup_sparse |
149+
| layers.embedding_ops | embedding_lookup_sparse_with_distributed_aggregation | Replaced by emedding_lookup_sparse_v2 |
150+
| layers.feature_column | ALL | Better version available in tf.feature_column |
151+
| layers.initizalizers | xavier_initializer | tf.keras has a glorot_normal and glorot_uniform |
152+
| layers.initizalizers | variance_scaling_initializer | Exists in tf.keras.initializers |
153+
| layers.layers | avg_pool2d | Exists in tf.keras.layers |
154+
| layers.layers | avg_pool3d | Exists in tf.keras.layers |
155+
| layers.layers | batch_norm | Exists in tf.keras.layers |
156+
| layers.layers | bias_add | Exists in tf.keras.layers |
157+
| layers.layers | conv1d | Exists in tf.keras.layers |
158+
| layers.layers | conv2d | Exists in tf.keras.layers |
159+
| layers.layers | conv3d | Exists in tf.keras.layers |
160+
| layers.layers | conv2d_in_plane | Functional Alias |
161+
| layers.layers | conv2d_transpose | Exists in tf.keras.layers |
162+
| layers.layers | conv3d_transpose | Exists in tf.keras.layers |
163+
| layers.layers | convolution | Exists in tf.keras.layers |
164+
| layers.layers | convolution1d | Exists in tf.keras.layers |
165+
| layers.layers | convolution2d | Exists in tf.keras.layers |
166+
| layers.layers | convolution2d_transpose | Exists in tf.keras.layers |
167+
| layers.layers | convolution3d | Exists in tf.keras.layers |
168+
| layers.layers | convolution3d_transpose | Exists in tf.keras.layers |
169+
| layers.layers | dropout | Exists in tf.keras.layers |
170+
| layers.layers | elu | Exists in tf.keras.layers |
171+
| layers.layers | flatten | Exists in tf.keras.layers |
172+
| layers.layers | fully_connected | Exists in tf.keras.layers |
173+
| layers.layers | gdn | Functional interface of GDN |
174+
| layers.layers | images_to_sequence | No OSS uses found / Functional paradigm |
175+
| layers.layers | linear | Exists in tf.keras.layers |
176+
| layers.layers | pool | Exists in tf.keras.layers |
177+
| layers.layers | max_pool2d| Exists in tf.keras.layers |
178+
| layers.layers | max_pool3d | Exists in tf.keras.layers |
179+
| layers.layers | one_hot_encoding | Exists in tf.keras / Uses collections |
180+
| layers.layers | relu | Exists in tf.keras.layers |
181+
| layers.layers | relu6 | Exists in tf.keras.layers |
182+
| layers.layers | repeat | Exists as sequential model |
183+
| layers.layers | separable_conv2d | Exists in tf.keras.layers |
184+
| layers.layers | separable_convolution2d | Exists in tf.keras.layers |
185+
| layers.layers | softmax | Exists in tf.keras.layers |
186+
| layers.layers | stack | Exists as sequential model / Uses variable scoping |
187+
| layers.layers | unit_norm | Exists in linalg |
188+
| layers.layers | legacy_fully_connected | Legacy layer |
189+
| layers.layers | legacy_linear | Legacy layer |
190+
| layers.layers | legacy_relu | Legacy layer |
191+
| layers.regularizers | l1_regularizer | Available in tf.keras.regularizers |
192+
| layers.regularizers | l2_regularizer | Available in tf.keras.regularizers |
193+
| layers.regularizers | l1_l2_regularizer | Available in tf.keras.regularizers |
194+
| layers.regularizers | sum_regularizer | Trivial convience wrapper |
195+
| layers.regularizers | apply_regularization | Uses collections |
196+
| layers.rev_block_lib | rev_block | Functional paradigm for RevBlock |
197+
| layers.summaries | summarize_tensors | Trivial list comprehension |
198+
| layers.summaries | summarize_collection | Uses collections |
199+
| layers.summaries | summarize_activations | Uses collecftions |
200+
| layers.target_column | ALL | Deprecated since Estimators |
201+
| layers.utils | collect_named_output | Unsupported tensor alias API |
202+
| layers.utils | append_tensor_alias | Unsupported tensor alias API |
203+
| layers.utils | gather_tensors_aliases | Unsupported tensor alias API |
204+
| layers.utils | get_tensor_aliases | Unsupported tensor alias API |
205+
| layers.utils | convert_collection_to_dict | Uses collections |
206+
| layers.utils | static_cond | Simple wrapper / No OSS use |
207+
| layers.utils | smart_cond | Simple wrapper / Little OSS use |
208+
| layers.utils | get_variable_collections | Uses collections |
209+
| layers.utils | channel_dimension | Simple wrapper / No OSS use |
210+
| layers.utils | last_dimension | Simple wrapper / No OSS use |
211+
| layers.utils | two_element_tuple | No OSS use |
212+
| layers.utils | n_positive_integers | No OSS use |
213+
| nn.cross_entropy | ALL | Deprecated Losses |
214+
| losses.loss_ops | ALL | Available in core tf.losses |
215+
216+
217+
218+
**Notes:**
219+
* More details of our code review can be found in [this spreadsheet](https://docs.google.com/spreadsheets/d/1hYJchHp1y1t2U6htq5UXxMxWlGxxtOyyNHDF8_qhtQQ/edit#gid=185512613)
220+
* We used [this analysis tool](https://tf-contrib-analyzer.herokuapp.com/) to detect OSS usage.
221+
222+
## Questions and Discussion Topics
223+
224+
* Are there any modules being excluded from the move that you feel have substantial value to the community?
225+
* Are there any new modules that you feel should be added to addons from somewhere else apart from tf.contrib
226+
* We're actively collecting volunteers to help move, refactor and/or maintain in Addons (Please reachout to our [mailing list](https://groups.google.com/a/tensorflow.org/forum/#!forum/addons)
227+
or [gitter channel](https://gitter.im/tensorflow/sig-addons) if you have interest in helping our community.
228+
229+
## After Request Notes
230+
* Now that the review period has ended, please post all suggested
231+
additions/removals directly to the tensorflow/addons [issues page](https://github.com/tensorflow/addons/issues)

0 commit comments

Comments
 (0)