qubvel / efficientnet

Implementation of EfficientNet model. Keras and TensorFlow Keras.
https://arxiv.org/abs/1905.11946
Apache License 2.0
2.07k stars 472 forks source link

EfficientNetL2 tf.keras error #121

Open kurnianggoro opened 4 years ago

kurnianggoro commented 4 years ago

Hello,

it seems that the efficientnetL2 is having problem i tried to load model but i got an error for both imagenet and noisy student checkpoint

the error message is something like this (i deleted some of them for simplicity)

/usr/local/lib/python3.6/dist-packages/efficientnet/model.py in EfficientNet(width_coefficient, depth_coefficient, default_resolution, dropout_rate, drop_connect_rate, depth_divisor, blocks_args, model_name, include_top, weights, input_tensor, input_shape, pooling, classes, **kwargs)
    386                                   activation=activation,
    387                                   drop_rate=drop_rate,
--> 388                                   prefix=block_prefix)
    389                 block_num += 1
    390 

/usr/local/lib/python3.6/dist-packages/efficientnet/model.py in mb_conv_block(inputs, block_args, activation, drop_rate, prefix)
    240             x = Dropout(drop_rate,
    241                         noise_shape=(None, 1, 1, 1),
--> 242                         name=prefix + 'drop')(x)
    243         x = layers.add([x, inputs], name=prefix + 'add')
    244 

'ValueError: rate must be a scalar tensor or a float in the range [0, 1), got 1'

You can check the code here https://colab.research.google.com/drive/1IyKFQut8q23jKeGOgXzSmn4e2qKGTyzl

I dont really understand why this is happened since the code for this model is basically same with the other versions but using different parameters in width_coefficient,depth_coefficient,default_resolution,dropout_rate

kurnianggoro commented 4 years ago

Maybe related to this one #117

kd2718 commented 4 years ago

So I did some digging, and it looks like this is not ready for use yet. First of all, there is an error when calculating the drop_rate here. The default value of drop_connect_rate will return a drop_rate of 1. You can get around this by calling efficientnetL2 with the parameter drop_connect_rate=0.05. However, there will be new errors when the weights for L2 are downloaded.

In the weights file, there is no key for efficientnet-l2. Checking the reference to the weights download release, you can see that there is indeed no weights for L2.

Basically, EfficientNetL2 does not seem to be implemented, nor are there weights for it yet.

ucb-pb commented 3 years ago

What's the error involving drop_rate? Has it been fixed?