Keras to tf.keras
See original GitHub issueHas anyone ported this (awesome) tutorial to tf.keras from keras? My motivation is related to training in AWS SageMaker where there is some required functionality in a tf.contrib package.
For the most part this seems pretty straight forward but I hit a wall (exceeded my talent) on keras_ssd300.py
File "/home/ubuntu/projects/rev-tensorflow-ssd/models/keras_ssd300.py", line 318, in ssd_300
conv4_3_norm = L2Normalization(gamma_init=20, name='conv4_3_norm')(conv4_3)
File "/home/ubuntu/anaconda3/envs/tensorflow_p36/lib/python3.6/site-packages/tensorflow/python/keras/engine/base_layer.py", line 538, in __call__
self._maybe_build(inputs)
File "/home/ubuntu/anaconda3/envs/tensorflow_p36/lib/python3.6/site-packages/tensorflow/python/keras/engine/base_layer.py", line 1603, in _maybe_build
self.build(input_shapes)
File "/home/ubuntu/projects/rev-tensorflow-ssd/models/keras_layers/keras_layer_L2Normalization.py", line 64, in build
self.trainable_weights = [self.gamma]
File "/home/ubuntu/anaconda3/envs/tensorflow_p36/lib/python3.6/site-packages/tensorflow/python/keras/engine/base_layer.py", line 1639, in __setattr__
super(Layer, self).__setattr__(name, value)
AttributeError: can't set attribute
If I understand this correctly, this is feeding conv4_3 into the L2 normalization layer It is trying to set the attribute: self.trainable_weights = [self.gamma] from a(n added) print statement, it looks like self.gamma = [<tf.Variable ‘conv4_3_norm/conv4_3_norm_gamma:0’ shape=(512,) dtype=float32>]
Can anyone offer a clue here?
Issue Analytics
- State:
- Created 4 years ago
- Comments:10 (1 by maintainers)
Top Results From Across the Web
tf.keras.Model | TensorFlow v2.11.0
Model groups layers into an object with training and inference features.
Read more >Keras vs. tf.keras: What's the difference in TensorFlow 2.0?
Now that TensorFlow 2.0 is released both keras and tf.keras are in sync, implying that keras and tf.keras are still separate projects; however, ......
Read more >What is the difference between keras and tf.keras?
tf.keras is the Tensorflow specific implementation of the Keras API specification. It adds the framework the support for many Tensorflow specific features ...
Read more >How to convert your Keras models to Tensorflow - Medium
build and train your model in Keras; Use K.get_session() to get TF session and output the model as .pb file; Load .pb file...
Read more >The Model class - Keras
tf.keras.Model(). Model groups layers into an object with training and inference features. Arguments. inputs: The input(s) of the model: a keras.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I also got the same error. Do you find any solution for that?
tried the same fix and got
“ValueError: Dimensions must be equal, but are 512 and 64 for ‘conv4_3_norm/mul’ (op: ‘Mul’) with input shapes: [?,64,64,512], [64].” tf 1.13