Paddle icon indicating copy to clipboard operation
Paddle copied to clipboard

how to make a lambda layer to wrap python function to a network layer?

Open yttbgf opened this issue 8 years ago • 4 comments

1.how to make a lambda layer to wrap python function to a network layer?just like keras. no trainable parameters. 2.how to construct a matrix as hidden layer parameter with constant value such as 0 or 1,or by some calculation. I want to implement such features: layer1.output + [0 1 1 ..](with same shape with layer1.output)

yttbgf avatar May 03 '18 12:05 yttbgf

  1. Python lambda layer is not supported in Paddle.

  2. Do you mean values of the parameter is fixed to layer1.output + [0 1 1 ..]? If so, the parameter is not trainable?

It is easy to implement the second feature in Fluid. The code will be like this:

var1 = layer1(...)
bias = fluid.layers.fill_constant(shape=var1.shape,dtype=..., value=1)
var2 = var1 + bias
res = fluid.fc(input=..., param_attr=fluid.ParamAttr(name=var2.name, trainable=False))

JiayiFeng avatar May 03 '18 15:05 JiayiFeng

but how to implement the function in v2 version?

yttbgf avatar May 04 '18 02:05 yttbgf

In V2 API, outputs of layers and parameters are implemented by differnet data structs. So the feature you need is not supported.

JiayiFeng avatar May 04 '18 03:05 JiayiFeng

您好,此issue在近一个月内暂无更新,我们将于今天内关闭。若在关闭后您仍需跟进提问,可重新开启此问题,我们将在24小时内回复您。因关闭带来的不便我们深表歉意,请您谅解~感谢您对PaddlePaddle的支持! Hello, this issue has not been updated in the past month. We will close it today for the sake of other user‘s experience. If you still need to follow up on this question after closing, please feel free to reopen it. In that case, we will get back to you within 24 hours. We apologize for the inconvenience caused by the closure and thank you so much for your support of PaddlePaddle Group!

shanyi15 avatar Aug 15 '18 11:08 shanyi15