Skip to content

Commit ed1c9ea

Browse files
committed
fix issues
1 parent 682ec5a commit ed1c9ea

File tree

8 files changed

+36
-5
lines changed

8 files changed

+36
-5
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ developments that cannot be integrated into core TensorFlow
1212
## Contents
1313
| Sub-Package | Addon | Reference |
1414
|:----------------------- |:----------- |:---------------------------- |
15+
| addons.activations | Sparsemax | https://arxiv.org/abs/1602.02068 |
1516
| addons.image | transform | |
1617
| addons.layers | Maxout | https://arxiv.org/abs/1302.4389 |
1718
| addons.layers | PoinareNormalize | https://arxiv.org/abs/1705.08039 |
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
# Addons - Layers
2+
3+
## Contents
4+
| Layer | Reference |
5+
|:----------------------- |:-----------------------------|
6+
| Sparsemax | https://arxiv.org/abs/1602.02068 |
7+
8+
9+
## Contribution Guidelines
10+
#### Standard API
11+
In order to conform with the current API standard, all activations
12+
must:
13+
* Be a `tf.function`.
14+
* Have the signature `fn(input, axis=-1, name=None)`.
15+
* [Register as a keras global object](https://github.com/tensorflow/addons/blob/master/tensorflow_addons/utils/python/keras_utils.py)
16+
so it can be serialized properly.
17+
* Add the addon to the `py_library` in this sub-package's BUILD file.
18+
19+
#### Testing Requirements
20+
* Simple unittests that demonstrate the layer is behaving as expected.
21+
* When applicable, run all unittests with TensorFlow's
22+
`@run_all_in_graph_and_eager_modes` decorator.
23+
* Add a `py_test` to this sub-package's BUILD file.
24+
25+
#### Documentation Requirements
26+
* Update the table of contents in the project's central README.
27+
* Update the table of contents in this sub-package's README.

tensorflow_addons/activations/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Copyright 2016 The TensorFlow Authors. All Rights Reserved.
1+
# Copyright 2019 The TensorFlow Authors. All Rights Reserved.
22
#
33
# Licensed under the Apache License, Version 2.0 (the "License");
44
# you may not use this file except in compliance with the License.

tensorflow_addons/activations/python/sparsemax.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121

2222
from tensorflow_addons.utils.python import keras_utils
2323

24+
@tf.function
2425
@keras_utils.register_keras_custom_object
2526
def sparsemax(logits, axis=-1, name=None):
2627
"""Sparsemax activation function [1].

tensorflow_addons/activations/python/sparsemax_test.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -270,7 +270,8 @@ def test_gradient_against_estimate(self, dtype=None):
270270

271271
(jacob_sym, ), (jacob_num, ) = tf.test.compute_gradient(
272272
lambda logits: sparsemax(logits),
273-
[z])
273+
[z],
274+
delta=1e-6)
274275
self.assertAllCloseAccordingToType(jacob_sym, jacob_num)
275276

276277
if __name__ == '__main__':

tensorflow_addons/layers/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,5 +20,5 @@
2020

2121
from tensorflow_addons.layers.python.maxout import Maxout
2222
from tensorflow_addons.layers.python.poincare import PoincareNormalize
23-
from tensorflow_addons.layers.python.wrappers import WeightNormalization
2423
from tensorflow_addons.layers.python.sparsemax import Sparsemax
24+
from tensorflow_addons.layers.python.wrappers import WeightNormalization

tensorflow_addons/losses/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,5 +18,5 @@
1818
from __future__ import division
1919
from __future__ import print_function
2020

21-
from tensorflow_addons.losses.python.triplet import triplet_semihard_loss
2221
from tensorflow_addons.losses.python.sparsemax_loss import sparsemax_loss, SparsemaxLoss
22+
from tensorflow_addons.losses.python.triplet import triplet_semihard_loss

tensorflow_addons/utils/python/keras_utils.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,9 @@
1717
from __future__ import division
1818
from __future__ import print_function
1919

20-
from tensorflow.python.keras.utils import generic_utils
20+
# TODO: find public API alternative to these
2121
from tensorflow.python.keras.losses import LossFunctionWrapper
22+
from tensorflow.python.keras.utils import generic_utils
2223

2324

2425
def register_keras_custom_object(cls):

0 commit comments

Comments
 (0)