代码拉取完成,页面将自动刷新
from keras.models import Model
from keras.layers import Input, Conv3D, MaxPooling3D, Dense, GlobalMaxPooling3D, Dropout, BatchNormalization
from keras.optimizers import Adam
from config import *
def get_simplified_VGG_classifier():
inputs = Input((CLASSIFY_INPUT_WIDTH, CLASSIFY_INPUT_HEIGHT, CLASSIFY_INPUT_DEPTH, CLASSIFY_INPUT_CHANNEL))
x = Conv3D(16, (3, 3, 3), padding='same', activation='relu')(inputs)
x = Conv3D(16, (3, 3, 3), padding='same', activation='relu')(x)
x = MaxPooling3D(pool_size=(2, 2, 2))(x)
if TRAIN_CLASSIFY_USE_BN:
x = BatchNormalization()(x)
x = Conv3D(32, (3, 3, 3), padding='same', activation='relu')(x)
x = Conv3D(32, (3, 3, 3), padding='same', activation='relu')(x)
x = MaxPooling3D(pool_size=(2, 2, 2))(x)
if TRAIN_CLASSIFY_USE_BN:
x = BatchNormalization()(x)
x = Conv3D(64, (3, 3, 3), padding='same', activation='relu')(x)
x = Conv3D(64, (3, 3, 3), padding='same', activation='relu')(x)
x = Conv3D(64, (3, 3, 3), padding='same', activation='relu')(x)
x = MaxPooling3D(pool_size=(2, 2, 2))(x)
if TRAIN_CLASSIFY_USE_BN:
x = BatchNormalization()(x)
x = Conv3D(128, (3, 3, 3), padding='same', activation='relu')(x)
x = Conv3D(128, (3, 3, 3), padding='same', activation='relu')(x)
x = Conv3D(128, (3, 3, 3), padding='same', activation='relu')(x)
# x = MaxPooling3D(pool_size=(2, 2, 2))(x)
#
# x = Conv3D(512, (3, 3, 3), padding='same', activation='relu')(x)
# x = Conv3D(512, (3, 3, 3), padding='same', activation='relu')(x)
# x = Conv3D(512, (3, 3, 3), padding='same', activation='relu')(x)
x = GlobalMaxPooling3D()(x)
# x = Flatten()(x)
x = Dense(32, activation='relu')(x)
x = Dropout(0.5)(x)
x = Dense(2, activation='softmax')(x)
model = Model(inputs=inputs, outputs=x)
model.compile(optimizer=Adam(lr=TRAIN_CLASSIFY_LEARNING_RATE), loss='binary_crossentropy', metrics=['accuracy'])
return model
def get_full_VGG_classifier():
inputs = Input((CLASSIFY_INPUT_WIDTH, CLASSIFY_INPUT_HEIGHT, CLASSIFY_INPUT_DEPTH, CLASSIFY_INPUT_CHANNEL))
x = inputs
x = Conv3D(32, (3, 3, 3), padding='same', activation='relu')(x)
x = Conv3D(32, (3, 3, 3), padding='same', activation='relu')(x)
x = MaxPooling3D(pool_size=(2, 2, 2))(x)
if TRAIN_CLASSIFY_USE_BN:
x = BatchNormalization()(x)
x = Conv3D(64, (3, 3, 3), padding='same', activation='relu')(x)
x = Conv3D(64, (3, 3, 3), padding='same', activation='relu')(x)
x = MaxPooling3D(pool_size=(2, 2, 2))(x)
if TRAIN_CLASSIFY_USE_BN:
x = BatchNormalization()(x)
x = Conv3D(128, (3, 3, 3), padding='same', activation='relu')(x)
x = Conv3D(128, (3, 3, 3), padding='same', activation='relu')(x)
x = Conv3D(128, (3, 3, 3), padding='same', activation='relu')(x)
x = MaxPooling3D(pool_size=(2, 2, 2))(x)
if TRAIN_CLASSIFY_USE_BN:
x = BatchNormalization()(x)
x = Conv3D(256, (3, 3, 3), padding='same', activation='relu')(x)
x = Conv3D(256, (3, 3, 3), padding='same', activation='relu')(x)
x = Conv3D(256, (3, 3, 3), padding='same', activation='relu')(x)
x = MaxPooling3D(pool_size=(2, 2, 2))(x)
if TRAIN_CLASSIFY_USE_BN:
x = BatchNormalization()(x)
x = Conv3D(512, (3, 3, 3), padding='same', activation='relu')(x)
x = Conv3D(512, (3, 3, 3), padding='same', activation='relu')(x)
x = Conv3D(512, (3, 3, 3), padding='same', activation='relu')(x)
x = GlobalMaxPooling3D()(x)
x = Dense(32, activation='relu')(x)
x = Dropout(0.5)(x)
x = Dense(2, activation='softmax')(x)
model = Model(inputs=inputs, outputs=x)
model.compile(optimizer=Adam(lr=TRAIN_CLASSIFY_LEARNING_RATE), loss='binary_crossentropy', metrics=['accuracy'])
return model
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。