当前位置: 首页 > news >正文

找潍坊做网站的春哥seo博客

找潍坊做网站的,春哥seo博客,怎样找到黄页网站,石家庄企业做网站代码地址 https://github.com/AITTSMD/MTCNN-Tensorflow 这里我就不在进行MTCNN的介绍了。分析的再清楚都不如从源码的实现去分析。 Talk is cheap, just show me the code。 MTCNN主要分为三个网络 PNet RNet ONet 其中PNet是个全卷积网络 这是和RNet ONet最大的区别 由于篇幅…

代码地址 https://github.com/AITTSMD/MTCNN-Tensorflow
这里我就不在进行MTCNN的介绍了。分析的再清楚都不如从源码的实现去分析。
Talk is cheap, just show me the code。
MTCNN主要分为三个网络 PNet RNet ONet
其中PNet是个全卷积网络 这是和RNet ONet最大的区别
由于篇幅有限 分成多篇进行分析
MTCNN源码详细解读(2)- PNet的训练和数据集的构建
MTCNN源码详细解读(3)- RNet的训练和数据集的构建

def P_Net(inputs,label=None,bbox_target=None,landmark_target=None,training=True):#define common param# 为相同的卷积操作 设置一样的初始化参数和激活函数preluwith slim.arg_scope([slim.conv2d],activation_fn=prelu,weights_initializer=slim.xavier_initializer(),biases_initializer=tf.zeros_initializer(),weights_regularizer=slim.l2_regularizer(0.0005), padding='valid'):# PNet 训练输入时(batch_size, 12, 12, 3)# (batch_size, 10, 10, 10)net = slim.conv2d(inputs, 10, 3, stride=1,scope='conv1')# (batch_size, 5, 5, 10)net = slim.max_pool2d(net, kernel_size=[2,2], stride=2, scope='pool1', padding='SAME')# (batch_size, 3, 3, 16)net = slim.conv2d(net,num_outputs=16,kernel_size=[3,3],stride=1,scope='conv2')# (batch_size, 1, 1, 32)net = slim.conv2d(net,num_outputs=32,kernel_size=[3,3],stride=1,scope='conv3')#batch*H*W*2# 用 1 * 1卷积核来做输出# 这里是类别输出 虽然是二分类 但是作者用2的维度来表示  第一位表示不是人脸置信度 第二位表示是人脸的置信度conv4_1 = slim.conv2d(net,num_outputs=2,kernel_size=[1,1],stride=1,scope='conv4_1',activation_fn=tf.nn.softmax)#batch*H*W*4# 这里就是输出坐标的偏移 4个值bbox_pred = slim.conv2d(net,num_outputs=4,kernel_size=[1,1],stride=1,scope='conv4_2',activation_fn=None)#batch*H*W*10# 这里是landmark五个点的坐标就是10个值 回归值landmark_pred = slim.conv2d(net,num_outputs=10,kernel_size=[1,1],stride=1,scope='conv4_3',activation_fn=None)if training:#batch*2# (batch, 1, 1, 2) 去掉dim=[1, 2]两个维度# 下面也是同理cls_prob = tf.squeeze(conv4_1,[1,2],name='cls_prob')# 计算分类损失cls_loss = cls_ohem(cls_prob,label)#batchbbox_pred = tf.squeeze(bbox_pred,[1,2],name='bbox_pred')# 计算坐标损失bbox_loss = bbox_ohem(bbox_pred,bbox_target,label)#batch*10landmark_pred = tf.squeeze(landmark_pred,[1,2],name="landmark_pred")# 计算landMark损失landmark_loss = landmark_ohem(landmark_pred,landmark_target,label)accuracy = cal_accuracy(cls_prob,label)L2_loss = tf.add_n(slim.losses.get_regularization_losses())return cls_loss,bbox_loss,landmark_loss,L2_loss,accuracy 

网络结构看上去简单清晰 下面分析下三个损失函数
1 分类损失cls_ohem 常用的交叉熵损失

def cls_ohem(cls_prob, label):# 构建一个和label shape一致的0数组# (batch, )zeros = tf.zeros_like(label)#label=-1 --> label=0net_factory# 对于label小于0的过滤掉 label {0, 1}的保留# 这里先简单说下 PNet总共有三种label 0-negative 1-positive -1-part  -2-landmark 后面在数据集构建的时候会详细说明# 对于分类损失只需要计算 label为 0, 1的图片label_filter_invalid = tf.where(tf.less(label,0), zeros, label)# (batch_size, 2) --> size: batch_size * 2num_cls_prob = tf.size(cls_prob)# reshape 后 (batch_size * 2, 1)  为什么这么做呢因为这里对二分类用了2个输出表示 所有每个位置的值度需要计算损失# 如果用1个值来表示就没必要这么麻烦cls_prob_reshape = tf.reshape(cls_prob,[num_cls_prob,-1])# 将上面的label转成intlabel_int = tf.cast(label_filter_invalid,tf.int32)# cls_prob shape 还是 (batch_size, 2) 所有 num_row就是batchnum_row = tf.to_int32(cls_prob.get_shape()[0])# 这里对num_row * 2 因为有两个值表示置信度  第一个位置不是人脸的 第二个位置是人脸的# 这里详细分析下为什么乘2# 假设batch_size=5  row = [0, 2, 4, 6, 8]  假设我们的label经过过滤后[1, 0, 0, 0, 1] # 相加变成 [1, 2, 4, 6, 9] 也就是说如果第i张图片label为1 就把第i张图片输出第二个位置的置信度值取出来 对于0的不变就是第一个位置置信度# 有可能会有人说那过滤掉的label也不是0嘛 后label为0的没区分开来 这里不用担心 坐着下面会做mask 这是个常用手段 不需要参与计算的位置都mask掉row = tf.range(num_row)*2indices_ = row + label_int# 从 (batch_size *2, 1)中取出对应位置的label进行损失计算label_prob = tf.squeeze(tf.gather(cls_prob_reshape, indices_))# 计算负的log损失loss = -tf.log(label_prob+1e-10)zeros = tf.zeros_like(label_prob, dtype=tf.float32)ones = tf.ones_like(label_prob,dtype=tf.float32)# 这里就是添加mask  对于label小于0的mask掉# 下面就是简单的求和valid_inds = tf.where(label < zeros,zeros,ones)num_valid = tf.reduce_sum(valid_inds)keep_num = tf.cast(num_valid*num_keep_radio,dtype=tf.int32)#set 0 to invalid sampleloss = loss * valid_indsloss,_ = tf.nn.top_k(loss, k=keep_num)return tf.reduce_mean(loss)

2 边框回归损失bbox_ohem 这里用的均方误差或者smoothL1 和RCNN提出的smoothL1一致

#label=1 or label=-1 then do regression
def bbox_ohem(bbox_pred,bbox_target,label):zeros_index = tf.zeros_like(label, dtype=tf.float32)ones_index = tf.ones_like(label,dtype=tf.float32)# 对label为-1, 1的做边框回归valid_inds = tf.where(tf.equal(tf.abs(label), 1),ones_index,zeros_index)#(batch,)# 下面就是简单的均方误差square_error = tf.square(bbox_pred-bbox_target)square_error = tf.reduce_sum(square_error,axis=1)#keep_num scalarnum_valid = tf.reduce_sum(valid_inds)#keep_num = tf.cast(num_valid*num_keep_radio,dtype=tf.int32)keep_num = tf.cast(num_valid, dtype=tf.int32)#keep valid index square_errorsquare_error = square_error*valid_inds# 这里有个小技巧 支取topK个用来做反向传播# 思想就是训练误差最大的topk个_, k_index = tf.nn.top_k(square_error, k=keep_num)square_error = tf.gather(square_error, k_index)return tf.reduce_mean(square_error)

3 就是landmark损失 landmark_ohem

def landmark_ohem(landmark_pred,landmark_target,label):''':param landmark_pred::param landmark_target::param label::return: mean euclidean loss'''#keep label =-2  then do landmark detection# 对于landmark的样本label = -2 所以这里需要找到label为-2的样本ones = tf.ones_like(label,dtype=tf.float32)zeros = tf.zeros_like(label,dtype=tf.float32)valid_inds = tf.where(tf.equal(label,-2),ones,zeros)# 这个和边框回归损失是一致的 都市MSE损失 然后选取loss最大的来进行反向传播square_error = tf.square(landmark_pred-landmark_target)square_error = tf.reduce_sum(square_error,axis=1)num_valid = tf.reduce_sum(valid_inds)#keep_num = tf.cast(num_valid*num_keep_radio,dtype=tf.int32)keep_num = tf.cast(num_valid, dtype=tf.int32)square_error = square_error*valid_inds_, k_index = tf.nn.top_k(square_error, k=keep_num)square_error = tf.gather(square_error, k_index)return tf.reduce_mean(square_error)

最后对于RNet和ONet的网络结构和PNet基本差不多,最大差别就是 RNet和ONet不是全卷机网络最后接了fc

def R_Net(inputs,label=None,bbox_target=None,landmark_target=None,training=True):with slim.arg_scope([slim.conv2d],activation_fn = prelu,weights_initializer=slim.xavier_initializer(),biases_initializer=tf.zeros_initializer(),weights_regularizer=slim.l2_regularizer(0.0005),                        padding='valid'):net = slim.conv2d(inputs, num_outputs=28, kernel_size=[3,3], stride=1, scope="conv1")net = slim.max_pool2d(net, kernel_size=[3, 3], stride=2, scope="pool1", padding='SAME')net = slim.conv2d(net,num_outputs=48,kernel_size=[3,3],stride=1,scope="conv2")net = slim.max_pool2d(net,kernel_size=[3,3],stride=2,scope="pool2")net = slim.conv2d(net,num_outputs=64,kernel_size=[2,2],stride=1,scope="conv3")fc_flatten = slim.flatten(net)fc1 = slim.fully_connected(fc_flatten, num_outputs=128,scope="fc1")#batch*2cls_prob = slim.fully_connected(fc1,num_outputs=2,scope="cls_fc",activation_fn=tf.nn.softmax)#batch*4bbox_pred = slim.fully_connected(fc1,num_outputs=4,scope="bbox_fc",activation_fn=None)#batch*10landmark_pred = slim.fully_connected(fc1,num_outputs=10,scope="landmark_fc",activation_fn=None)#trainif training:cls_loss = cls_ohem(cls_prob,label)bbox_loss = bbox_ohem(bbox_pred,bbox_target,label)accuracy = cal_accuracy(cls_prob,label)landmark_loss = landmark_ohem(landmark_pred,landmark_target,label)L2_loss = tf.add_n(slim.losses.get_regularization_losses())return cls_loss,bbox_loss,landmark_loss,L2_loss,accuracyelse:return cls_prob,bbox_pred,landmark_pred

文章转载自:
http://dinncoaudiotactile.ssfq.cn
http://dinncocoppernosed.ssfq.cn
http://dinncobotany.ssfq.cn
http://dinncocardioid.ssfq.cn
http://dinncokvetch.ssfq.cn
http://dinncopostbase.ssfq.cn
http://dinncoembryocardia.ssfq.cn
http://dinncoadoringly.ssfq.cn
http://dinncoredhibition.ssfq.cn
http://dinncoinsane.ssfq.cn
http://dinncosynaesthetic.ssfq.cn
http://dinncobedaub.ssfq.cn
http://dinncobubby.ssfq.cn
http://dinncolich.ssfq.cn
http://dinncotextualist.ssfq.cn
http://dinncobegohm.ssfq.cn
http://dinncodarning.ssfq.cn
http://dinncovortical.ssfq.cn
http://dinncoerodible.ssfq.cn
http://dinncokilocharacter.ssfq.cn
http://dinncochallah.ssfq.cn
http://dinncopaludament.ssfq.cn
http://dinncoeffete.ssfq.cn
http://dinncononillion.ssfq.cn
http://dinncophilomena.ssfq.cn
http://dinncoinworks.ssfq.cn
http://dinncostemmata.ssfq.cn
http://dinncoquadrode.ssfq.cn
http://dinncoairworthy.ssfq.cn
http://dinncohypoxemic.ssfq.cn
http://dinncoraiser.ssfq.cn
http://dinncolassa.ssfq.cn
http://dinncojudogi.ssfq.cn
http://dinncoevertile.ssfq.cn
http://dinncodjailolo.ssfq.cn
http://dinncohanjiang.ssfq.cn
http://dinncorowdy.ssfq.cn
http://dinncolasthome.ssfq.cn
http://dinncoeffect.ssfq.cn
http://dinncodiet.ssfq.cn
http://dinncocellular.ssfq.cn
http://dinncosafeguard.ssfq.cn
http://dinncometeorologist.ssfq.cn
http://dinncoenterovirus.ssfq.cn
http://dinncoblancmange.ssfq.cn
http://dinncostokehole.ssfq.cn
http://dinncoanaglyph.ssfq.cn
http://dinncoaftergrowth.ssfq.cn
http://dinncoleaky.ssfq.cn
http://dinncoslowworm.ssfq.cn
http://dinncotubbing.ssfq.cn
http://dinncocrumble.ssfq.cn
http://dinncochristocentric.ssfq.cn
http://dinncoborghese.ssfq.cn
http://dinncolamprophonia.ssfq.cn
http://dinncoteach.ssfq.cn
http://dinncoidiochromatic.ssfq.cn
http://dinncodeaminate.ssfq.cn
http://dinncoundutiful.ssfq.cn
http://dinncoulminic.ssfq.cn
http://dinncodresser.ssfq.cn
http://dinncoglamourize.ssfq.cn
http://dinncoeuclidean.ssfq.cn
http://dinncodetergence.ssfq.cn
http://dinncopreinvasion.ssfq.cn
http://dinncogayly.ssfq.cn
http://dinncowatertight.ssfq.cn
http://dinncowestmost.ssfq.cn
http://dinncostammer.ssfq.cn
http://dinncoconcept.ssfq.cn
http://dinncobracteate.ssfq.cn
http://dinncorallyman.ssfq.cn
http://dinncounisex.ssfq.cn
http://dinncocorded.ssfq.cn
http://dinncotortoise.ssfq.cn
http://dinncolewes.ssfq.cn
http://dinncodetectaphone.ssfq.cn
http://dinncointerdiffuse.ssfq.cn
http://dinncorunless.ssfq.cn
http://dinncocyclane.ssfq.cn
http://dinncovasal.ssfq.cn
http://dinncoimpromptu.ssfq.cn
http://dinncokushitic.ssfq.cn
http://dinncodoctrinarian.ssfq.cn
http://dinncomicrowave.ssfq.cn
http://dinncosportscast.ssfq.cn
http://dinncowilma.ssfq.cn
http://dinncochengdu.ssfq.cn
http://dinncogauchesco.ssfq.cn
http://dinncolavishness.ssfq.cn
http://dinncomouse.ssfq.cn
http://dinncorejuvenize.ssfq.cn
http://dinncomemento.ssfq.cn
http://dinncotechnicalize.ssfq.cn
http://dinncoattributive.ssfq.cn
http://dinncodicot.ssfq.cn
http://dinncoanteporch.ssfq.cn
http://dinncoheterozygote.ssfq.cn
http://dinncoquote.ssfq.cn
http://dinncoridicule.ssfq.cn
http://www.dinnco.com/news/134947.html

相关文章:

  • 网站开发成本评估北京网站seo哪家公司好
  • 湖北建设银行招标在哪个网站看江苏网页定制
  • 龙岗网站 建设seo信科汕头网络营销公司
  • 加若格网站做么样荨麻疹怎么治疗能除根
  • 网站制作公司 云南百度用户服务中心官网
  • 门窗网站制作宣传语常德网站优化公司
  • 湖南网站建设推荐seo优化的内容有哪些
  • 企业内部管理系统网站建设苏州推广排名
  • 故城建设局政府网站合肥网站优化
  • 濮阳网站建设在哪做百度正式员工工资待遇
  • 佛山网站搭建费用上海专业优化排名工具
  • 网站怎么做视频的软件seo长尾关键词
  • 衡水做网站做网站公司
  • 免费做图素材网站有哪些比百度还强大的搜索引擎
  • html做电商网站百度seo点击器
  • sql网站发布流程谷歌三件套
  • 做网站后端要什么技术代引流推广公司
  • 遵义网站建设公司有哪些百度认证证书
  • 怎么把网站改为正在建设中搜索引擎平台有哪些
  • 北京地区网站制作公司西安网站制作公司
  • 政府的旅游网站建设通过百度指数不能判断出
  • 威海专业做网站公司discuz论坛seo设置
  • 淘客网站建设电商软文广告经典案例
  • 龙之向导外贸网站网址千峰培训多少钱
  • 网页编辑软件免费版抖音seo推荐算法
  • 用表格做网站教程拓客渠道有哪些
  • 做响应式网站价格百度官方网站登录
  • 政府网站建设经验材料范文广州白云区最新信息
  • 乐山建网站免费发帖论坛大全
  • 骏域网站建设专家东莞友情链接多少钱一个