在Caffe中使用自定义切片层,直到运行时才知道“ top”的大小?

时间:2019-05-09 13:33:11

标签: caffe pycaffe

使用咖啡有可能吗?据我所知,设置和重塑都是在不了解数据的情况下运行的。我的自定义切片层(Python层)旨在“动态”选择智能对以进行暹罗训练。但是,每个小批量之间的类分布略有不同。

我正在尝试将其实现为以下形式的Python层:

<!-- language: lang-py -->
class custom_slice_layer(caffe.Layer):
  def setup(self, bottom, top):
    # check top, bottom blobsvecs match desired size.

  def reshape(self, bottom, top):
    # reshape to the right size?  This is The error happens during the reshape step.

  def forward(self, bottom, top):
    # pick desired pairs for siamese training (to be fed into the default contrastive loss layer)

  def backward(self, top, propagate_down, bottom):
    # combine the gradients for backprop

可以理解的是,我目前在运行时收到此错误:

I0509 09:21:46.434281 14750 net.cpp:122] Setting up custom_slice_name
I0509 09:21:46.434306 14750 net.cpp:129] Top shape: (0)
I0509 09:21:46.434312 14750 net.cpp:129] Top shape: (0)
I0509 09:21:46.434319 14750 net.cpp:129] Top shape: (0)
I0509 09:21:46.434324 14750 net.cpp:137] Memory required for data: 790788800
I0509 09:21:46.434332 14750 layer_factory.hpp:77] Creating layer contrastiveloss
I0509 09:21:46.434350 14750 net.cpp:84] Creating Layer contrastiveloss
I0509 09:21:46.434360 14750 net.cpp:406] contrastiveloss <- ip2A
I0509 09:21:46.434370 14750 net.cpp:406] contrastiveloss <- ip2B
I0509 09:21:46.434377 14750 net.cpp:406] contrastiveloss <- sim
I0509 09:21:46.434387 14750 net.cpp:380] contrastiveloss -> contrastive_loss
F0509 09:21:46.434793 14750 blob.hpp:122] Check failed: axis_index < num_axes() (0 vs. 0) axis 0 out of range for 0-D Blob with shape (0)
*** Check failure stack trace: ***
Abort (core dumped)

0 个答案:

没有答案