leondgarse / keras_cv_attention_models

Keras beit,caformer,CMT,CoAtNet,convnext,davit,dino,efficientdet,edgenext,efficientformer,efficientnet,eva,fasternet,fastervit,fastvit,flexivit,gcvit,ghostnet,gpvit,hornet,hiera,iformer,inceptionnext,lcnet,levit,maxvit,mobilevit,moganet,nat,nfnets,pvt,swin,tinynet,tinyvit,uniformer,volo,vanillanet,yolor,yolov7,yolov8,yolox,gpt2,llama2, alias kecam
MIT License
595 stars 95 forks source link

UserWarning raised when I instantiate a model #114

Closed PierreCarceller closed 11 months ago

PierreCarceller commented 1 year ago

Hello

When I instantiate a template with this code :

from keras_cv_attention_models import efficientnet basic_model = efficientnet.EfficientNetV2B0(input_shape=(112, 112, 3), num_classes=0)

I get this warning:

UserWarning: The initializer VarianceScaling is unseeded and being called multiple times, which will return identical values each time (even if the initializer is unseeded). Please update your code to provide a seed to the initializer, or avoid using the same initalizer instance more than once. f"The initializer {self.__class__.__name__} is unseeded "

The warning is quite clear and a fix doesn't seem too painful

leondgarse commented 1 year ago

Ya, I'm also bothered by this warning, will check it soon.

leondgarse commented 1 year ago

This should be fixed in new release 1.3.10. Currently using CONV_KERNEL_INITIALIZER = "glorot_uniform" instead of CONV_KERNEL_INITIALIZER = keras.initializers.VarianceScaling(scale=2.0, mode="fan_out", distribution="truncated_normal") in keras_cv_attention_models/common_layers.py#L9.

leondgarse commented 11 months ago

Closing, as global initializer is removed.