0
$\begingroup$

Suppose we have a simple neural network as follows:

f = NetChain[ { LinearLayer[32], ElementwiseLayer["ReLU"], LinearLayer[16], ElementwiseLayer["ReLU"], LinearLayer[1] }, "Input" -> 3, "Output" -> 1 ] 

How can we represent the function g as a neural network that behaves like the function below?

g[v_] := Max@Map[f[Append[v, #]] &, Range[10000]] 
$\endgroup$

1 Answer 1

0
$\begingroup$

Here is one possible solution in case someone has a similar question.

op = NetGraph[ <| "f" -> f, "cat" -> CatenateLayer[] |>, { {NetPort["Input1"], NetPort["Input2"]} -> "cat" -> "f" -> NetPort["Output"] } ] g = NetGraph[ <| "repl" -> ReplicateLayer[10000], "const" -> NetArrayLayer["Array" -> Transpose[{Range[10000]}], "LearningRateMultipliers" -> None], "mapthread" -> NetMapThreadOperator[op], "max" -> AggregationLayer[Max, All] |>, { NetPort["Input"] -> "repl" -> "mapthread", "const" -> "mapthread" -> "max" -> NetPort["Output"] } ] 
$\endgroup$

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.