5
$\begingroup$

how can I represent the derivative of a network (e.g. NetGraph or NetChain) as a network? I have tried it with FunctionLayer[] and NetPortGradient, but without success.

I would be very pleased to receive an answer.

Minimal working example:

Let the following layer be given

unet = FunctionLayer[#*FeedForwardNet[#] + 1 &, "Output" -> "Scalar"] 

whereby

FeedForwardNet = NetChain[ {LinearLayer[50, "Input" -> "Real"], LogisticSigmoid,LinearLayer[1, "Output" -> "Scalar"]}]

I now want to determine the derivative of unet, but as a network.

With

NetInitialize[unet][1, NetPortGradient["Input"]]

I get the derivative at the point 1. However, I cannot define this as a layer. When I try I get an error:

FunctionLayer[NetInitialize[u][#, NetPortGradient["Input"]] &]

Error: Cannot interpret FunctionLayer[<>][#1, #2] & as a network.

I would not like to carry out a numerical calculation of the derivative.

$\endgroup$
2
  • $\begingroup$ Welcome to the Mathematica Stack Exchange. In order to make the question more concrete, please add a minimal working example along with a desired output. $\endgroup$
    – Syed
    Commented Jun 5, 2022 at 12:19
  • $\begingroup$ Hello, I have now done that. Thank you for the advice. $\endgroup$
    – haro21
    Commented Jun 5, 2022 at 12:35

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.