how to make a lambda layer to wrap python function to a network layer?
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)
-
Python lambda layer is not supported in Paddle.
-
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))
but how to implement the function in v2 version?
In V2 API, outputs of layers and parameters are implemented by differnet data structs. So the feature you need is not supported.
您好,此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!