标签:激活 vat app 函数 线性 模型 axis 对象 初始化
使用卷积、池化、非线性映射(tanh或者sigmoid)。
model = Sequential() model.add(Conv2D(filters=6, kernel_size=(5,5), padding=‘valid‘, input_shape=(1,28,28), activation=‘tanh‘)) model.add(MaxPooling2D(pool_size=(2,2))) model.add(Conv2D(filters=16, kernel_size=(5,5), padding=‘valid‘, activation=‘tanh‘)) model.add(MaxPooling2D(pool_size=(2,2))) model.add(Flatten()) model.add(Dense(120, activation=‘tanh‘)) model.add(Dense(84, activation=‘tanh‘)) model.add(Dense(10, activation=‘softmax‘))
引入了Relu激活函数。
使用了Dropout。
加强了训练机制:使用了GPU,进行了数据增强。
model = Sequential() model.add(Conv2D(96,(11,11),strides=(4,4),input_shape=(227,227,3),padding=‘valid‘,activation=‘relu‘,kernel_initializer=‘uniform‘)) model.add(MaxPooling2D(pool_size=(3,3),strides=(2,2))) model.add(Conv2D(256,(5,5),strides=(1,1),padding=‘same‘,activation=‘relu‘,kernel_initializer=‘uniform‘)) model.add(MaxPooling2D(pool_size=(3,3),strides=(2,2))) model.add(Conv2D(384,(3,3),strides=(1,1),padding=‘same‘,activation=‘relu‘,kernel_initializer=‘uniform‘)) model.add(Conv2D(384,(3,3),strides=(1,1),padding=‘same‘,activation=‘relu‘,kernel_initializer=‘uniform‘)) model.add(Conv2D(256,(3,3),strides=(1,1),padding=‘same‘,activation=‘relu‘,kernel_initializer=‘uniform‘)) model.add(MaxPooling2D(pool_size=(3,3),strides=(2,2))) model.add(Flatten()) model.add(Dense(4096,activation=‘relu‘)) model.add(Dropout(0.5)) model.add(Dense(4096,activation=‘relu‘)) model.add(Dropout(0.5)) model.add(Dense(1000,activation=‘softmax‘))
model = Sequential() model.add(Conv2D(64,(3,3),strides=(1,1),input_shape=(224,224,3),padding=‘same‘,activation=‘relu‘,kernel_initializer=‘uniform‘)) model.add(Conv2D(64,(3,3),strides=(1,1),padding=‘same‘,activation=‘relu‘,kernel_initializer=‘uniform‘)) model.add(MaxPooling2D(pool_size=(2,2))) model.add(Conv2D(128,(3,2),strides=(1,1),padding=‘same‘,activation=‘relu‘,kernel_initializer=‘uniform‘)) model.add(Conv2D(128,(3,3),strides=(1,1),padding=‘same‘,activation=‘relu‘,kernel_initializer=‘uniform‘)) model.add(MaxPooling2D(pool_size=(2,2))) model.add(Conv2D(256,(3,3),strides=(1,1),padding=‘same‘,activation=‘relu‘,kernel_initializer=‘uniform‘)) model.add(Conv2D(256,(3,3),strides=(1,1),padding=‘same‘,activation=‘relu‘,kernel_initializer=‘uniform‘)) model.add(MaxPooling2D(pool_size=(2,2))) model.add(Conv2D(512,(3,3),strides=(1,1),padding=‘same‘,activation=‘relu‘,kernel_initializer=‘uniform‘)) model.add(Conv2D(512,(3,3),strides=(1,1),padding=‘same‘,activation=‘relu‘,kernel_initializer=‘uniform‘)) model.add(MaxPooling2D(pool_size=(2,2))) model.add(Conv2D(512,(3,3),strides=(1,1),padding=‘same‘,activation=‘relu‘,kernel_initializer=‘uniform‘)) model.add(Conv2D(512,(3,3),strides=(1,1),padding=‘same‘,activation=‘relu‘,kernel_initializer=‘uniform‘)) model.add(MaxPooling2D(pool_size=(2,2))) model.add(Flatten()) model.add(Dense(4096,activation=‘relu‘)) model.add(Dropout(0.5)) model.add(Dense(4096,activation=‘relu‘)) model.add(Dropout(0.5)) model.add(Dense(1000,activation=‘softmax‘))
def Conv2d_BN(x, nb_filter,kernel_size, padding=‘same‘,strides=(1,1),name=None): if name is not None: bn_name = name + ‘_bn‘ conv_name = name + ‘_conv‘ else: bn_name = None conv_name = None x = Conv2D(nb_filter,kernel_size,padding=padding,strides=strides,activation=‘relu‘,name=conv_name)(x) x = BatchNormalization(axis=3,name=bn_name)(x) return x def Inception(x,nb_filter): branch1x1 = Conv2d_BN(x,nb_filter,(1,1), padding=‘same‘,strides=(1,1),name=None) branch3x3 = Conv2d_BN(x,nb_filter,(1,1), padding=‘same‘,strides=(1,1),name=None) branch3x3 = Conv2d_BN(branch3x3,nb_filter,(3,3), padding=‘same‘,strides=(1,1),name=None) branch5x5 = Conv2d_BN(x,nb_filter,(1,1), padding=‘same‘,strides=(1,1),name=None) branch5x5 = Conv2d_BN(branch5x5,nb_filter,(1,1), padding=‘same‘,strides=(1,1),name=None) branchpool = MaxPooling2D(pool_size=(3,3),strides=(1,1),padding=‘same‘)(x) branchpool = Conv2d_BN(branchpool,nb_filter,(1,1),padding=‘same‘,strides=(1,1),name=None) x = concatenate([branch1x1,branch3x3,branch5x5,branchpool],axis=3) return x
def Conv_Block(inpt,nb_filter,kernel_size,strides=(1,1), with_conv_shortcut=False): x = Conv2d_BN(inpt,nb_filter=nb_filter,kernel_size=kernel_size,strides=strides,padding=‘same‘) x = Conv2d_BN(x, nb_filter=nb_filter, kernel_size=kernel_size,padding=‘same‘) if with_conv_shortcut: shortcut = Conv2d_BN(inpt,nb_filter=nb_filter,strides=strides,kernel_size=kernel_size) x = add([x,shortcut]) return x else: x = add([x,inpt]) return x
标签:激活 vat app 函数 线性 模型 axis 对象 初始化
原文地址:https://www.cnblogs.com/liuyunfeng/p/9349682.html