简体   繁体   English

如何在Tensorflow框架中将L2-Loss函数用于对象检测CNN?

[英]How can I use L2-Loss function for Object-detection CNN in Tensorflow framework?

I'm studying about tensorflow (exactly Object Detection using CNN) 我正在研究张量流(使用CNN进行精确的对象检测)

I have already studied about Classification, but Object-Detection is Regression problem, so I am confused loss function and total network implementation. 我已经研究过分类,但是对象检测是回归问题,因此我对损失函数和整个网络的实现感到困惑。

In classification problem, I should use- 在分类问题中,我应该使用-

tf.nn.softmax_cross_entropy_with_logits(logits=result, labels=Y) tf.nn.softmax_cross_entropy_with_logits(logits =结果,标签= Y)

(result is my CNN output tensor) (结果是我的CNN输出张量)

but in regression problem, like sementic-segmentation and object detection, I found that I have to use l2-loss function. 但是在回归问题中,例如分割和对象检测,我发现我必须使用l2损失函数。

tf.nn.l2_loss(t=result) tf.nn.l2_loss(T =结果)

I don't know how can I use this function because I cannot use tf.argmax function. 我不知道如何使用此函数,因为无法使用tf.argmax函数。

[Source Code 1] Classification, used softmax and tf.argmax [源代码1]分类,使用softmax和tf.argmax

cross_entropy = tf.reduce_mean(tf.nn.softmax_cross_entropy_with_logits(logits=result, labels=Y))
print("* Cross Entropy SIZE : " + str(cross_entropy))

Result_argmax = tf.argmax(tf.nn.softmax(result), 1)
Label_argmax = tf.argmax(Y, 1)
print("* Result Argmax : ", Result_argmax)
print("* Label Argmax : ", Label_argmax)

ay = tf.argmax(tf.nn.softmax(result), 1)
ly = tf.argmax(tf.nn.softmax(Y), 1)
correct_prediction = tf.equal(Result_argmax, Label_argmax)
print("* tf.argmax : " + str(Result_argmax))
accuracy = tf.reduce_mean(tf.cast(correct_prediction, tf.float32))

train_step = tf.train.AdamOptimizer(0.0001 * batchsize).minimize(cross_entropy)

this is so easy and I totally understood. 这是如此简单,我完全理解。

[Source Code 2] Regression, used l2_loss function [源代码2]回归,使用了l2_loss函数

l2_loss = tf.reduce_mean(tf.nn.l2_loss(t=result))
print("** L2 Loss SIZE : " + str(l2_loss))
train_step = tf.train.AdamOptimizer(0.0001 * batchsize).minimize(l2_loss)

????????

Is that correct? 那是对的吗? I cannot understand how to do box location learning. 我不明白如何进行盒子位置学习。

Also, There is my learning monitor which is captured. 另外,还有我的学习监视器。

在此处输入图片说明

Really, Really I can't understand. 真的,真的我听不懂。 Please HELP ME! 请帮我!

(last, here is my session image captured.) (最后,这是我的会话图像。) 在此处输入图片说明

Object detection consists of classification and regression, that is, not only do we have to correctly classify an object on the image, but also we need to correctly locate the object. 对象检测包括分类和回归,也就是说,我们不仅需要正确地对图像上的对象进行分类,而且还需要正确地定位对象。

Although some object detection frameworks do look like a regression model (YOLO, SSD), but the loss function is not as simple as a L2 loss. 虽然某些对象检测框架确实看起来像回归模型(YOLO,SSD),但是损失函数并不像L2损失那么简单。 In fact, the loss function consists of two parts, crossentropy loss for classification and regression loss for localization, and L2 loss is usually used for regression loss here. 事实上,损失函数由两个部分组成, crossentropy用于分类和损失regression损失为本地化和L2损失通常用于regression损失这里。

Here are the loss functions of some common object detection models. 这是一些常见物体检测模型的损失函数。

SSD model. SSD型号。 在此处输入图片说明

YOLO model YOLO模型

在此处输入图片说明

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Tensorflow 对象检测使我的系统过载 - Tensorflow object-detection overload my system Tensorflow 对象检测运行错误 - Tensorflow Object-detection running error 在Tensorflow对象检测中评估预训练模型时出错(tensorflow.python.framework.errors_impl.NotFoundError :) - Error when evaluating pretrained model in Tensorflow object-detection (tensorflow.python.framework.errors_impl.NotFoundError:) 我如何使用 tensorflow 对象检测来仅检测人? - How can i use tensorflow object detection to only detect persons? 无法为Tensorflow对象检测API编译.proto文件 - Unable to compile .proto files for Tensorflow object-detection API 使用张量流训练对象检测模型时,错误索引 [0] = 0 不在 [0, 0) 中 - Error indices[0] = 0 is not in [0, 0) while training an object-detection model with tensorflow 在Tensorflow对象检测中尝试评估相关模型时出错 - Error when trying to evaluate pertained model in tensorflow object-detection 自定义数据集上的tensorflow对象检测API评估 - tensorflow object-detection api eval on custom dataset 自定义损失 function 用于在 Tensorflow 2.0+ 中使用 CNN 进行分布外检测 - Custom loss function for out of distribution detection using CNN in Tensorflow 2.0+ 我在对象检测和 pycotools.mask 方面遇到问题 - I am having an issue with object-detection and with pycotools.mask
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM