tf.keras

Backpropagating through multiple forward passes

旧巷老猫 提交于 2020-08-05 09:39:38
问题 In usual backprop, we forward-prop once, compute gradients, then apply them to update weights. But suppose we wish to forward-prop twice , and backprop through both , and apply gradients only then (skip on first). Suppose the following: x = tf.Variable([2.]) w = tf.Variable([4.]) with tf.GradientTape(persistent=True) as tape: w.assign(w * x) y = w * w # w^2 * x print(tape.gradient(y, x)) # >>None From docs, a tf.Variable is a stateful object, which blocks gradients , and weights are tf

Backpropagating through multiple forward passes

亡梦爱人 提交于 2020-08-05 09:37:03
问题 In usual backprop, we forward-prop once, compute gradients, then apply them to update weights. But suppose we wish to forward-prop twice , and backprop through both , and apply gradients only then (skip on first). Suppose the following: x = tf.Variable([2.]) w = tf.Variable([4.]) with tf.GradientTape(persistent=True) as tape: w.assign(w * x) y = w * w # w^2 * x print(tape.gradient(y, x)) # >>None From docs, a tf.Variable is a stateful object, which blocks gradients , and weights are tf

'Error While Encoding with Hub.KerasLayer' while using TFF

依然范特西╮ 提交于 2020-07-23 06:53:05
问题 An error is being generated while training a federated model that uses hub.KerasLayer. The details of error and stack trace is given below. The complete code is available of gist https://gist.github.com/aksingh2411/60796ee58c88e0c3f074c8909b17b5a1. Help and suggestion in this regard would be appreciated. Thanks. from tensorflow import keras def create_keras_model(): encoder = hub.load("https://tfhub.dev/google/tf2-preview/gnews-swivel-20dim/1") return tf.keras.models.Sequential([ hub

'Error While Encoding with Hub.KerasLayer' while using TFF

牧云@^-^@ 提交于 2020-07-23 06:52:04
问题 An error is being generated while training a federated model that uses hub.KerasLayer. The details of error and stack trace is given below. The complete code is available of gist https://gist.github.com/aksingh2411/60796ee58c88e0c3f074c8909b17b5a1. Help and suggestion in this regard would be appreciated. Thanks. from tensorflow import keras def create_keras_model(): encoder = hub.load("https://tfhub.dev/google/tf2-preview/gnews-swivel-20dim/1") return tf.keras.models.Sequential([ hub

'Error While Encoding with Hub.KerasLayer' while using TFF

依然范特西╮ 提交于 2020-07-23 06:51:24
问题 An error is being generated while training a federated model that uses hub.KerasLayer. The details of error and stack trace is given below. The complete code is available of gist https://gist.github.com/aksingh2411/60796ee58c88e0c3f074c8909b17b5a1. Help and suggestion in this regard would be appreciated. Thanks. from tensorflow import keras def create_keras_model(): encoder = hub.load("https://tfhub.dev/google/tf2-preview/gnews-swivel-20dim/1") return tf.keras.models.Sequential([ hub

'Error While Encoding with Hub.KerasLayer' while using TFF

…衆ロ難τιáo~ 提交于 2020-07-23 06:50:55
问题 An error is being generated while training a federated model that uses hub.KerasLayer. The details of error and stack trace is given below. The complete code is available of gist https://gist.github.com/aksingh2411/60796ee58c88e0c3f074c8909b17b5a1. Help and suggestion in this regard would be appreciated. Thanks. from tensorflow import keras def create_keras_model(): encoder = hub.load("https://tfhub.dev/google/tf2-preview/gnews-swivel-20dim/1") return tf.keras.models.Sequential([ hub

tf.keras HDF5 Model and Keras HDF5 Model

耗尽温柔 提交于 2020-07-22 10:11:50
问题 I want to convert a Keras model to Tensorflow Lite model. When I examined the documentation, it is stated that we can use tf.keras HDF5 models as input. Does it mean I can use my saved HDF5 Keras model as input to it or tf.keras HDF5 model and Keras HDF5 models are different things? Documentation: https://www.tensorflow.org/lite/convert Edit: I could convert my Keras model to Tensorflow Lite model with using this API, but I didn't test it yet. My code: converter = tf.lite.TFLiteConverter.from

tf.keras HDF5 Model and Keras HDF5 Model

大城市里の小女人 提交于 2020-07-22 10:11:47
问题 I want to convert a Keras model to Tensorflow Lite model. When I examined the documentation, it is stated that we can use tf.keras HDF5 models as input. Does it mean I can use my saved HDF5 Keras model as input to it or tf.keras HDF5 model and Keras HDF5 models are different things? Documentation: https://www.tensorflow.org/lite/convert Edit: I could convert my Keras model to Tensorflow Lite model with using this API, but I didn't test it yet. My code: converter = tf.lite.TFLiteConverter.from

Failed to load Tensorboard

倖福魔咒の 提交于 2020-07-16 10:40:19
问题 ERROR: Failed to launch TensorBoard (exited with 1). Contents of stderr: Traceback (most recent call last): File "/home/arshad/anaconda3/bin/tensorboard", line 10, in sys.exit(run_main()) File "/home/arshad/anaconda3/lib/python3.7/site-packages/tensorboard/main.py", line 58, in run_main default.get_plugins() + default.get_dynamic_plugins(), File "/home/arshad/anaconda3/lib/python3.7/site-packages/tensorboard/default.py", line 110, in get_dynamic_plugins for entry_point in pkg_resources.iter

Why am I getting None gradient error in keras custom loss function?

泄露秘密 提交于 2020-06-29 06:41:08
问题 I am trying to train a convolutional auto encoder, along with the bounding box for penalizing the inside the boundign box region, for anomaly detection. My custom loss function and supporting functions are below. def assymetric_loss(input_bboxes): def custom_loss(input_images,recons_images): losses=[] for i in range(20): input_image=input_images[i] recons_image=recons_images[i] bbox=input_bboxes[i] #check_null=tf.equal(tf.size(bbox) , 0) x = tf.Variable(-1.0, dtype=tf.float32) check_equal=tf