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

Could you share wingloss example #31

Open
zys1994 opened this issue Jun 17, 2019 · 15 comments
Open

Could you share wingloss example #31

zys1994 opened this issue Jun 17, 2019 · 15 comments

Comments

@zys1994
Copy link

zys1994 commented Jun 17, 2019

Could you share wingloss in train prototxt example like EuclideanLoss

layer {
  name: "loss"    
  type: "EuclideanLoss"
  bottom: "fc2"
  bottom: "label"
  top: "loss"
  loss_weight: 100
}
@briantse100
Copy link

@xialuxi @zys1994 Hi, how do you set the wing loss parameter? I have set the landmark label to [-1,1]. And I have set the wing loss parameter (w=0.3, e=2), it does not converge. As follow is the author suggestion.
I need python caffe version of wingloss
You can normalise the label to [0,1], but then you have to change the wing loss parameters and learning rate as well. I used a label in [0,64] for CNN6 and I did not normalise the wing loss by the number of batch size

@zys1994
Copy link
Author

zys1994 commented Jun 20, 2019

(w=10,e=2) is fine

@zys1994
Copy link
Author

zys1994 commented Jun 21, 2019

@xialuxi @briantse100
how to use Wingloss? when i use WingLoss layer like this

layer {
  name: "landmarkloss"
  type: "WingLoss"
  bottom: "fc4"
  bottom: "hdf_data"
  top: "landmarkloss"
  loss_weight: 1
  include {
    phase: TRAIN
  }
  wing_loss_param{
    w: 10
    epsilon: 2 
  }
}

when i train,it makes wrong

*** Aborted at 1561083953 (unix time) try "date -d @1561083953" if you are using GNU date ***
PC: @     0x7f32043cfa9e (unknown)
*** SIGSEGV (@0x10514f09c00) received by PID 20569 (TID 0x7f3206ffbac0) from PID 351312896; stack trace: ***
    @     0x7f32042924b0 (unknown)
    @     0x7f32043cfa9e (unknown)
    @     0x7f320630a8b0 caffe::WingLossLayer<>::Forward_gpu()
    @     0x7f320615bbc1 caffe::Net<>::ForwardFromTo()
    @     0x7f320615bcc7 caffe::Net<>::Forward()
    @     0x7f32062e1ee8 caffe::Solver<>::Step()
    @     0x7f32062e2a8a caffe::Solver<>::Solve()
    @           0x40e54b train()
    @           0x40a6dd main
    @     0x7f320427d830 __libc_start_main
    @           0x40b139 _start
    @                0x0 (unknown)
^C

@xialuxi
Copy link
Owner

xialuxi commented Jun 21, 2019

你试一下使用cpu模式,看正不正常?

@zys1994
Copy link
Author

zys1994 commented Jun 21, 2019

cpu目前可以train,不过速度很慢 。 gpu版本是出了什么问题吗

@xialuxi
Copy link
Owner

xialuxi commented Jun 21, 2019

等我有时间了改一下就好了。

@briantse100
Copy link

briantse100 commented Jun 21, 2019

@zys1994, 可以参考faster-rcnn中的smoothL1loss

@xialuxi
Copy link
Owner

xialuxi commented Jun 21, 2019

WingLossForward 里面这样写会存在问题,gpu多线程对同一个变量操作了。

@xialuxi
Copy link
Owner

xialuxi commented Jun 21, 2019

将输出Dtype* out 改成, blob结构, 算完之后,再相加!

@zys1994
Copy link
Author

zys1994 commented Jun 21, 2019

cpu train了半天才6000个batch。期待你把gpu版本的改好来训 哈哈

@xialuxi
Copy link
Owner

xialuxi commented Jun 21, 2019

1, 你可以使用gpu训练, 只要把loss层的gpu代码屏蔽掉就行了,训练速度影响很小。
2、我稍微修改了下代码, 但是我没有测试,你可以自己试一试。

@zys1994
Copy link
Author

zys1994 commented Jun 21, 2019

make all -j 的时候报错了

src/caffe/layers/wing_loss_layer.cpp:28:47: error: ‘one_dot_data’ was not declared in this scope
void WingLossLayer<Dtype>::LayerSetUp(const vector<Blob<Dtype>*>& bottom, const vector<Blob<Dtype>*>& top)
{
    w = this->layer_param_.wing_loss_param().w();
    DCHECK(w > 0);
    epsilon = this->layer_param_.wing_loss_param().epsilon();
    DCHECK(epsilon >= 0);


    //_c = w * (1.0 - log(1.0 + w/epsilon)
    _c = w * (1.0 - log(1.0 + w/epsilon));

   // has_ignore_label_ = this->layer_param_.loss_param().has_ignore_label();
   // if (has_ignore_label_)
   // {
   //     ignore_label_ = this->layer_param_.loss_param().ignore_label();
   // }
    log_abs.ReshapeLike(*bottom[0]);
    caffe_set(bottom[0]->count(), Dtype(1.0), one_dot_data);
}

这里面最后一句的one_dot_data在哪声明

@xialuxi
Copy link
Owner

xialuxi commented Jun 21, 2019 via email

@zys1994
Copy link
Author

zys1994 commented Jun 22, 2019

改了之后make可以通过, 但用cpu,gpu 在train都会报错
用EuclideanLoss是可以跑的,应该还是Wingloss有点问题

F0622 10:32:27.929319 17830 blob.cpp:133] Check failed: data_ 
*** Check failure stack trace: ***
    @     0x7f44f71c15cd  google::LogMessage::Fail()
    @     0x7f44f71c3433  google::LogMessage::SendToLog()
    @     0x7f44f71c115b  google::LogMessage::Flush()
    @     0x7f44f71c3e1e  google::LogMessageFatal::~LogMessageFatal()
    @     0x7f44f79bf5eb  caffe::Blob<>::mutable_cpu_data()
    @     0x7f44f798a60d  caffe::WingLossLayer<>::LayerSetUp()
    @     0x7f44f7845027  caffe::Net<>::Init()
    @     0x7f44f784776e  caffe::Net<>::Net()
    @     0x7f44f79b735a  caffe::Solver<>::InitTrainNet()
    @     0x7f44f79b8825  caffe::Solver<>::Init()
    @     0x7f44f79b8b3f  caffe::Solver<>::Solver()
    @     0x7f44f79aaaf1  caffe::Creator_AdamSolver<>()
    @           0x40d98a  train()
    @           0x40a6dd  main
    @     0x7f44f5957830  __libc_start_main
    @           0x40b139  _start
    @              (nil)  (unknown)

@zys1994
Copy link
Author

zys1994 commented Jun 24, 2019

@xialuxi 目前在用wingloss train的时候报错可以帮忙看看吗?

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

3 participants