[英]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!
请帮我!
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. 这是一些常见物体检测模型的损失函数。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.