Last active
May 2, 2019 23:40
-
-
Save jackd/f345b1dcd75e0efa53ba912d169852ec to your computer and use it in GitHub Desktop.
gin-config keras bug
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
layers.Dense.kernel_regularizer = @regularizers.l2() | |
regularizers.l2.l = 1e-4 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from __future__ import absolute_import | |
from __future__ import division | |
from __future__ import print_function | |
import tensorflow as tf | |
import gin | |
# fails | |
Dense = tf.keras.layers.Dense | |
gin.config.external_configurable(Dense, module='layers') | |
# succeeds | |
# Dense = gin.config.external_configurable(tf.keras.layers.Dense, module='layers') | |
# succeeds | |
# @gin.configurable(module='layers') | |
# def Dense(units, kernel_regularizer=None): | |
# return tf.keras.layers.Dense(units, kernel_regularizer=kernel_regularizer) | |
gin.config.external_configurable( | |
tf.keras.regularizers.l2, module='regularizers') | |
gin.parse_config_files_and_bindings(['conf.gin'], []) | |
x = tf.zeros((5, 4)) | |
layer = Dense(10) | |
layer(x) | |
print(layer.kernel_regularizer) |
sguada
commented
May 2, 2019
•
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment