简体   繁体   中英

how can I use inception_resnet_v2 architecture

I'm working on a face liveness datection model, first I used mobilenet for transfer learning in the code below:

import keras
from keras import backend as K
from keras.layers.core import Dense, Activation
from keras.optimizers import Adam
from keras.metrics import categorical_crossentropy
from keras.preprocessing.image import ImageDataGenerator
from keras.preprocessing import image
from keras.models import Model
from keras.applications import imagenet_utils
from keras.layers import Dense,GlobalAveragePooling2D
from keras.applications import MobileNet
from keras.applications.mobilenet import preprocess_input
import numpy as np
import matplotlib.pyplot as plt
from keras.optimizers import Adam
from sklearn.metrics import classification_report, confusion_matrix

INIT_LR = 1e-5
BS = 32
EPOCHS = 20

# MobileNetV2
base_model = keras.applications.mobilenet_v2.MobileNetV2(input_shape=None, alpha=1.0, include_top=False, weights='imagenet', input_tensor=None, pooling=None, classes=2)

x=base_model.output # a luat outputul inainte de FC
x=GlobalAveragePooling2D()(x)
x=Dense(512,activation='relu')(x) #dense layer 3
preds=Dense(2,activation='softmax')(x) #final layer with softmax activation

# specify the inputs
# specify the outputs
# now a model has been created based on our architecture
new_model=Model(inputs=base_model.input, outputs=preds)

now I want to run it with inception_resnet_v2 in order to get another results to compare it with the first result, could you show me how to do it?

I'm working on a face liveness datection model, first I used mobilenet for transfer learning in the code below:

import keras
from keras import backend as K
from keras.layers.core import Dense, Activation
from keras.optimizers import Adam
from keras.metrics import categorical_crossentropy
from keras.preprocessing.image import ImageDataGenerator
from keras.preprocessing import image
from keras.models import Model
from keras.applications import imagenet_utils
from keras.layers import Dense,GlobalAveragePooling2D
from keras.applications import MobileNet
from keras.applications.mobilenet import preprocess_input
import numpy as np
import matplotlib.pyplot as plt
from keras.optimizers import Adam
from sklearn.metrics import classification_report, confusion_matrix

INIT_LR = 1e-5
BS = 32
EPOCHS = 20

# MobileNetV2
base_model = keras.applications.mobilenet_v2.MobileNetV2(input_shape=None, alpha=1.0, include_top=False, weights='imagenet', input_tensor=None, pooling=None, classes=2)

x=base_model.output # a luat outputul inainte de FC
x=GlobalAveragePooling2D()(x)
x=Dense(512,activation='relu')(x) #dense layer 3
preds=Dense(2,activation='softmax')(x) #final layer with softmax activation

# specify the inputs
# specify the outputs
# now a model has been created based on our architecture
new_model=Model(inputs=base_model.input, outputs=preds)

now I want to run it with inception_resnet_v2 in order to get another results to compare it with the first result, could you show me how to do it?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM