Closed wenhuihuang1979 closed 5 years ago
i solve it by importing layers,
@wenhuihuang1979 what do u mean by 'importing layers'? could u please explain a bit more
@shaunster0 I'm using tensorflow-gpu==2.1.0rc1, keras==2.3.1 pip install -U efficientnet
use this import efficientnet.tfkeras from tensorflow.keras.models import load_model
instead of import efficientnet.keras
@shaunster0 I'm using tensorflow-gpu==2.1.0rc1, keras==2.3.1 pip install -U efficientnet
use this import efficientnet.tfkeras from tensorflow.keras.models import load_model
instead of import efficientnet.keras
What works for me, but it is definitely something is wrong with the code.
If you don't want to install efficientnet you use this:
from tensorflow.keras.models import load_model
from tensorflow import nn
from tensorflow.keras.backend import shape
from tensorflow.keras.layers import Dropout
class FixedDropout(Dropout):
def _get_noise_shape(self, inputs):
if self.noise_shape is None:
return self.noise_shape
return tuple([shape(inputs)[i] if sh is None else sh for i, sh in enumerate(self.noise_shape)])
customObjects = {
'swish': nn.swish,
'FixedDropout': FixedDropout
}
model = load_model('model.h5', custom_objects=customObjects)
For the record, I had trained my model using efficientnet.keras.EfficientNetB0 and I had the same problem when I reloaded for inference.
I solved it by simply importing efficientnet.keras.
For the record, I had trained my model using efficientnet.keras.EfficientNetB0 and I had the same problem when I reloaded for inference.
I solved it by simply importing efficientnet.keras.
how, can you share your implementation please
when I try to load the trained model, it give me "ValueError: Unknown activation function:swish", do you know how to solve that? thanks a lot!