'data_format = value.lower(),error:'Tensor' object has no attribute 'lower'
I am fine-tuning a DCGAN. When I run this code:
tf.keras.layers.Flatten(
tf.abs(tf.multiply(self.mask, self.G) - tf.multiply(self.mask, self.images))), 1)
it turns out error:
Traceback (most recent call last):
File "train-dcgan.py", line 39, in <module>
is_crop=False, checkpoint_dir=FLAGS.checkpoint_dir)
File "E:\dcgan-completion.tensorflow-master\dcgan-completion.tensorflow-master\model.py", line 81, in __init__
self.build_model()
File "E:\dcgan-completion.tensorflow-master\dcgan-completion.tensorflow-master\model.py", line 137, in build_model
tf.abs(tf.multiply(self.mask, self.G) - tf.multiply(self.mask, self.images))), 1)
File "D:\anaconda\envs\labelme\lib\site-packages\tensorflow_core\python\keras\layers\core.py", line 588, in __init__
self.data_format = conv_utils.normalize_data_format(data_format)
File "D:\anaconda\envs\labelme\lib\site-packages\tensorflow_core\python\keras\utils\conv_utils.py", line 191, in normalize_data_format
data_format = value.lower()
AttributeError: 'Tensor' object has no attribute 'lower'
My tensorflow version is 2.1.0,but in this project,most of code use tensorflow 1.x,hope you can tell me the reason of error,thank you a lot!
Solution 1:[1]
Flatten layer should be
tf.keras.layers.Flatten()(tf.abs(tf.multiply(self.mask, self.G) - tf.multiply(self.mask, self.images))), 1)
For more details please refer here
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | TFer2 |
