'module 'tensorflow' has no attribute 'random_normal'
i was running this step and it had error
from efficientnet import EfficientNetB0 as Net
from efficientnet import center_crop_and_resize, preprocess_input
# loading pretrained conv base model
conv_base = Net(weights='imagenet', include_top=False,
input_shape=input_shape)
error:
AttributeError Traceback (most recent call last)
<ipython-input-13-34d286b24b60> in <module>()
2 from efficientnet import center_crop_and_resize, preprocess_input
3 # loading pretrained conv base model
----> 4 conv_base = Net(weights='imagenet', include_top=False, input_shape=input_shape)
4 frames
/content/efficientnet_keras_transfer_learning/efficientnet/model.py in __call__(***failed resolving arguments***)
65 kernel_height, kernel_width, _, out_filters = shape
66 fan_out = int(kernel_height * kernel_width * out_filters)
---> 67 return tf.random_normal(
68 shape, mean=0.0, stddev=np.sqrt(2.0 / fan_out), dtype=dtype)
69
AttributeError: module 'tensorflow' has no attribute 'random_normal'
Thank you so much
Solution 1:[1]
Google Colab by default uses Tensorflow 2.x, where this function is called tensorflow.random.normal. The repository you link to seems to be using Tensorflow 1.x, where it was called tensorflow.random_normal. You can either:
clone the repository and update its code to run correctly on the newer version, or
instruct Google Colab to use the old Tensorflow using this instruction before
import tensorflow:%tensorflow_version 1.x
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 | Amadan |
