paddlepaddle吧 关注:212贴子:310
  • 1回复贴,共1

py_func接口当遇到输出值维度会变化的如何处理

只看楼主收藏回复

例如下面的代码,输出的cond的的可变的[2, ?]这种情况怎么处理?
def my_where(x): cond = np.where(np.greater_equal(x, 0)) return cond cond = create_tmp_var(name='cond', dtype=label_int.dtype, shape=label_int.shape) cond = fluid.layers.py_func(func=my_where, x=label_int, out=cond) picked = fluid.layers.squeeze(cond, axes=[])


1楼2019-06-09 16:05回复
    因为python function是在executor运行时执行的,所以在python function中只能写纯python的代码,不要调用fluid的接口。另外直接print cls_prob_reshpae是不对的,需要执行时python function才会被执行


    2楼2019-06-09 16:06
    回复