Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

您好,我可能发现了一个在yolo_traing.py中的bug #6

Open
kill2013110 opened this issue Dec 2, 2021 · 2 comments
Open

您好,我可能发现了一个在yolo_traing.py中的bug #6

kill2013110 opened this issue Dec 2, 2021 · 2 comments

Comments

@kill2013110
Copy link

kill2013110 commented Dec 2, 2021

是这样的,因为我的数据长宽大概为256,640这样的,所以我准备设置将训练的inputshape也设置为256,640,但训练时损失会很快变为负数。
而当我全程使用正方形训练和测试都没有问题.使用inputshape为正方形训练,然后设置inputshape为矩形测试也没有问题
经过一路排查,应该是将y_true的x,y转为x,y的偏移量时grid_shapes[l]的长,宽顺序反了:
image

将其中的grid_shapes[l][:]改为grid_shapes[l][::-1]我的训练就正常了。
因为正方形长宽高相等,所以不影响,而矩形这样会导致偏移量有大于1的值产生,在使用keras.binary_crossentropy计算损失时,label大于1则会产生负损失。
keras.binary_crossentropy(label , logits, from_logits=True)的计算公式如下:
x = logits, z = labels
loss = max(x, 0) - x * z + log(1 + exp(-abs(x)))

@bubbliiiing
Copy link
Owner

好!我改一下,我自己检查一下

@bubbliiiing
Copy link
Owner

3Q

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants