Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

I am not able to import resnet from keras.applications module

I'm unable to import this module

import keras.applications.resnet

ModuleNotFoundError
in () ----> 1 import keras.applications.resnet

ModuleNotFoundError: No module named 'keras.applications.resnet'


keras resnet link

like image 344
Aayush Bajaj Avatar asked Feb 14 '19 02:02

Aayush Bajaj


3 Answers

try to use

from tensorflow.keras.applications.resnet50 import ResNet50
like image 105
alireza Avatar answered Oct 24 '22 07:10

alireza


Keras team hasn't included resnet, resnet_v2 and resnext in the current module, they will be added from Keras 2.2.5, as mentioned here.

For a workaround, you can use keras_applications module directly to import all ResNet, ResNetV2 and ResNeXt models, as given below

from keras_applications.resnet import ResNet50

Or if you just want to use ResNet50

from keras.applications.resnet50 import ResNet50

Alternatively, you can always build from source as mentioned here.

like image 27
suvigyavijay Avatar answered Oct 24 '22 05:10

suvigyavijay


Found a workaround to use ResNeXt in Keras 2.2.4 here.

ResNeXt50() function needs 4 more arguments: backend, layers, models and utils.

import keras
from keras_applications.resnext import ResNeXt50

model = ResNeXt50(weights='imagenet',
                  backend=keras.backend,
                  layers=keras.layers,
                  models=keras.models,
                  utils=keras.utils)
like image 6
Hsinwei Avatar answered Oct 24 '22 05:10

Hsinwei