Желілердің негізгі түсінігі 9



бет22/23
Дата30.05.2022
өлшемі0.55 Mb.
#458795
1   ...   15   16   17   18   19   20   21   22   23
Сламбек Б.Нейрондық желілер негізінде адамның бет-әлпет эмоциясын тану.2019

Б қосымшасының жалғасы


faces = np.asarray(faces)


faces = np.expand_dims(faces)
emotions = pd.get_dummies(data['emotion']).as_matrix() return faces, emotions
def preprocess_input(x, v2=True): x = x.astype('float32')
x = x / 255 if v2:
x = x - 0.5
x = x * 2 return x
data_generator = ImageDataGenerator( featurewise_center=False, featurewise_std_normalization=False, rotation_range=10, width_shift_range=0.1, height_shift_range=0.1, zoom_range=.1,
horizontal_flip=True)

model = mini_XCEPTION(input_shape, num_classes) regularization = l2(l2_regularization)


img_input = Input(input_shape)


x = Conv2D(8, (3, 3), strides=(1, 1), kernel_regularizer=regularization, use_bias=False)(img_input)
x = BatchNormalization()(x) x = Activation('relu')(x)
x = Conv2D(8, (3, 3), strides=(1, 1), kernel_regularizer=regularization, use_bias=False)(x)
x = BatchNormalization()(x) x = Activation('relu')(x)
residual = Conv2D(16, (1, 1), strides = (2, 2), padding = 'same', use_bias = False)(x)
residual = BatchNormalization()(residual)
x = SeparableConv2D(16, (3, 3), padding='same', kernel_regularizer = regularization, use_bias = False)(x)
x = BatchNormalization()(x) x = Activation('relu')(x)
x = SeparableConv2D(16, (3, 3), padding='same', kernel_regularizer = regularization, use_bias = False)(x)
x = BatchNormalization()(x)

Б қосымшасының жалғасы


x = MaxPooling2D((3, 3), strides=(2, 2), padding='same')(x) x = layers.add([x, residual])


residual = Conv2D(32, (1, 1), strides=(2, 2), padding='same', use_bias=False)(x)
residual = BatchNormalization()(residual)
x = SeparableConv2D(32, (3, 3), padding='same', kernel_regularizer = regularization, use_bias = False)(x)
x = BatchNormalization()(x) x = Activation('relu')(x)
x = SeparableConv2D(32, (3, 3), padding='same', kernel_regularizer = regularization, use_bias = False)(x)
x = BatchNormalization()(x)
x = MaxPooling2D((3, 3), strides=(2, 2), padding='same')(x) x = layers.add([x, residual])
residual = Conv2D(64, (1, 1), strides=(2, 2),padding='same', use_bias=False)(x)
residual = BatchNormalization()(residual)
x = SeparableConv2D(64, (3, 3), padding = 'same', kernel_regularizer = regularization,use_bias = False)(x)
x = BatchNormalization()(x) x = Activation('relu')(x)
x = SeparableConv2D(64, (3, 3), padding='same', kernel_regularizer = regularization,use_bias = False)(x)
x = BatchNormalization()(x)
x = MaxPooling2D((3, 3), strides=(2, 2), padding='same')(x) x = layers.add([x, residual])
residual = Conv2D(128, (1, 1), strides=(2, 2), padding='same', use_bias = False)(x)
residual = BatchNormalization()(residual)
x = SeparableConv2D(128, (3, 3), padding='same', kernel_regularizer = regularization, use_bias = False)(x)
x = BatchNormalization()(x) x = Activation('relu')(x)
x = SeparableConv2D(128, (3, 3), padding='same', kernel_regularizer = regularization, use_bias = False)(x)
x = BatchNormalization()(x)
x = MaxPooling2D((3, 3), strides=(2, 2), padding='same')(x) x = layers.add([x, residual])
x = Conv2D(num_classes, (3, 3), padding='same')(x) x = GlobalAveragePooling2D()(x)
output = Activation('softmax',name='predictions')(x) model = Model(img_input, output)


Достарыңызбен бөлісу:
1   ...   15   16   17   18   19   20   21   22   23




©dereksiz.org 2024
әкімшілігінің қараңыз

    Басты бет