问题如下:
I0807 22:23:04.734895 29440 net.cpp:465] Sharing parameters 'predict_param_0' owned by layer 'beam', param index 7
F0807 22:23:04.734915 29440 net.cpp:484] Check failed: this_blob->shape() == owner_blob->shape() Cannot share param 'predict_param_0' owned by layer 'beam' with layer 'predict'; shape mismatch. Owner layer param shape is 1000 2048 (2048000); sharing layer expects shape 10010 2000 (20020000)
*** Check failure stack trace: ***
在我使用caffe来实现scst网络的时候,修改双层lstm,并其中添加了一些全连接层。如下所示:
layer {name: "fc_att_0"type: "InnerProduct"bottom: "fc8_0"top: "fc8_reshape_0"param {name: "fc_param_0"}inner_product_param {num_output: 1000bias_term: falseweight_filler {type: "gaussian"std: 0.00999999977648}}}
为了进一步获得想要得到的含有权重的图像信息,将其进行全连接操作来增加纬度以便接下来的处理,并且设置共享参数为name: "fc_param_0"。在实现caption的20个相同的单元中,网络结构基本一致,所以可以象LSTM层一样共享参数。整个网络scst是为了得到奖励reward。所以要先得到baseline的值。这里可以用greedy或者beamsearch得到。在原作者定义的层beam中。网络如下
layer {name: "beam"type: "BeamSearch"bottom: "num_boxes"bottom: "spatial_features"bottom: "fc"bottom: "context"top: "caption"top: "log_prob"top: "log_prob_sequence"param {name: "embed_param"}param {name: "lstm0_param_0"}param {name: "lstm0_param_1"}param {name: "hidden_att_param_0"}param {name: "predict_att_param_0"}param {name: "lstm1_param_0"}param {name: "lstm1_param_1"}param {name: "fc_param_0" (之前这一行是没有的,自己在源网络中定义了其他共享的参数一定要在层之前把参数空间传进去,才不会报错,否则网络找不到共享的参数)}param {name: "predict_param_0"}param {name: "predict_param_1"}beam_search_param {net_param {layer {name: "input"type: "Input"top: "num_boxes"top: "spatial_features"top: "fc"top: "context"top: "input"input_param {shape {dim: 12dim: 1}shape {dim: 12dim: 100dim: 2048}shape {dim: 12dim: 100dim: 512}shape {dim: 12dim: 2048}shape {dim: 12dim: 1}}}layer {name: "lstm0_hidden_prev"type: "DummyData"top: "lstm0_hidden_prev"dummy_data_param {shape {dim: 12dim: 1000}}}layer {name: "lstm0_mem_cell_prev"type: "DummyData"top: "lstm0_mem_cell_prev"dummy_data_param {shape {dim: 12dim: 1000}}}
其中定义了每个时间步网络的操作,并且限定了如lstm和innerproduct等层共享参数名称和排序。之前为出现这个错误就是应为在设置全局参数时,调用作者的beam层中的拥有参数(owner layer)。网络由于没有定义name: "fc_param_0"的参数名,所以按照顺序加载了一个1000*2048的错误参数,为解决这个为题,应该在上述程序开辟一个新的param空间,这样就不会出错。
注:防止以后出错写的笔记