This repository was archived by the owner on May 21, 2025. It is now read-only.
Commit 1400f70
committed
Fix passing of keyword args to Dense layers in create_tower
Current behavior: kwargs are passed to tf.keras.Sequential.add, so they
are not passed on to tf.keras.layers.Dense as intended. For example,
when passing `use_bias=False` to create_tower with the kwarg name
`kernel_regularizer`, it throws an exception:
Traceback (most recent call last):
File "/Users/brussell/development/ranking/tensorflow_ranking/python/keras/layers_test.py", line 33, in test_create_tower_with_kwargs
tower = layers.create_tower([3, 2, 1], 1, activation='relu', use_bias=False)
File "/Users/brussell/development/ranking/tensorflow_ranking/python/keras/layers.py", line 70, in create_tower
model.add(tf.keras.layers.Dense(units=layer_width), **kwargs)
File "/usr/local/anaconda3/lib/python3.9/site-packages/tensorflow/python/trackable/base.py", line 205, in _method_wrapper
result = method(self, *args, **kwargs)
File "/usr/local/anaconda3/lib/python3.9/site-packages/keras/utils/traceback_utils.py", line 61, in error_handler
return fn(*args, **kwargs)
TypeError: add() got an unexpected keyword argument 'use_bias'
test_create_tower_with_kwargs
Fix: This PR fixes the behavior by shifting the closing paren of
tf.keras.layers.Dense to the correct location.1 parent dfae631 commit 1400f70
2 files changed
+7
-3
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
57 | 57 | | |
58 | 58 | | |
59 | 59 | | |
60 | | - | |
| 60 | + | |
61 | 61 | | |
62 | 62 | | |
63 | 63 | | |
| |||
67 | 67 | | |
68 | 68 | | |
69 | 69 | | |
70 | | - | |
| 70 | + | |
71 | 71 | | |
72 | 72 | | |
73 | 73 | | |
74 | 74 | | |
75 | 75 | | |
76 | | - | |
| 76 | + | |
77 | 77 | | |
78 | 78 | | |
79 | 79 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
28 | 28 | | |
29 | 29 | | |
30 | 30 | | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
31 | 35 | | |
32 | 36 | | |
33 | 37 | | |
| |||
0 commit comments