qubvel / efficientnet

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

What does FixedDropout layer does? #120

Open xiankgx opened 4 years ago

xiankgx commented 4 years ago

Dear author, your work on implementing EfficientNets for Keras is much appreciated.

I'm using your segmentation_models library which in turn uses this library. I trained a model in pure Keras (2.2.4) + TF v1.14.0. Using tensorflowjs_converter command line tool, I was able to convert the model to TF.js without any issues. However, when I try to do inference in TF.js, it is giving me two errors, swish activation function not implemented, and FixedDropout layer not implemented. I have implemented a custom swish layer in TF.js according to your code. However, I'm not too sure about FixedDropout.

According to your code, it says

"""Wrapper over custom dropout. Fix problem of ``None`` shape for tf.keras.
    It is not possible to define FixedDropout class as global object,
    because we do not have modules for inheritance at first time.
    Issue:
        https://github.com/tensorflow/tensorflow/issues/30946
    """

It seems it is just fixing some shape issue for tf.keras. Can I just subclass FixedDropout from Dropout in TensorFlow.js without overwriting the forward/call function?

YifeiYang210 commented 3 years ago

@xiankgx Thanks for your issue. I meet the same situation.

I trained a model in pure Keras(2.2.4) + TF 1.15.0. For HeadPoseEstimation task, I refered to the xiankg/HeadPoseEstimation-WHENet as my model and attempted to convert to a TF.js model.

So the question about the FixedDropout, Can I just subclass FixedDropout from Dropout in TensorFlow.js without overwriting the forward/call function?, does you solve it now?

And I'm new to TF.js, so I just wonder about the code. Can only refer the tensorflow.js official documents to deploy the code to mobile device or you use the other third party libraries available to help?

Thank you !

bilaltahseen commented 3 years ago

I am having the same issue when loading the model on raspberry Pi

YifeiYang210 commented 3 years ago

I succeed to load it. Subclass FixedDropout from Dropout MAY help!

jclaessens97 commented 2 years ago

@YifeiYang210 how did you create a subclass from that Dropout? I'm only able to create a subclass from Layer

elliestath commented 2 years ago

any update on this? I would like to call FixedDropout as I do for the other layers, e.g. keras.layers.Conv2D but keras.layers.FixedDropout gives an error AttributeError: module 'keras.layers' has no attribute 'FixedDropout'