2 deleted 4 characters in body edited May 23 at 15:25 Sjoerd Smit 6,5951313 silver badges2727 bronze badges Here is an example of how to use NetMapOperator to do this. Define a test function and generate training data from it: testFun = Function[x, Cos[x] + Sqrt[x]]; trainingData = Table[With[{ x = RandomReal[{0, 10}, {RandomInteger[{5, 20}], 1}] }, x -> Total[testFun /@ x] ], 100 ]; Dimensions /@ First[trainingData]  {8, 1} -> {1} As you can see, I'm mapping a n by 1 vector (with n chosen randomly) to a length-1 vector. This is easier to work with inside of the neural networks. Next, define a simple learnable mapping x -> y using NetChain with Ramp non-linearities. This effectively gives a piecewise linear model for testFun: regressionNet = NetChain[{5, Ramp, 5, Ramp, 1}] trainingNet = NetChain[{ NetMapOperator[regressionNet], AggregationLayer[Total, 1] }, "Input" -> {"Varying", 1} ]  Train the net and visualize the learned version of testFun: trainedNet = NetTrain[trainingNet, trainingData]; With[{ trainedFun = NetExtract[trainedNet, {1, "Net"}] }, Plot[{testFun[x], trainedFun[x]}, {x, 0, 10}] ]  You may not always get this result, so it may be neededfeel free to fiddle around with the training methods etc. Here is an example of how to use NetMapOperator to do this. Define a test function and generate training data from it: testFun = Function[x, Cos[x] + Sqrt[x]]; trainingData = Table[With[{ x = RandomReal[{0, 10}, {RandomInteger[{5, 20}], 1}] }, x -> Total[testFun /@ x] ], 100 ]; Dimensions /@ First[trainingData]  {8, 1} -> {1} As you can see, I'm mapping a n by 1 vector (with n chosen randomly) to a length-1 vector. This is easier to work with inside of the neural networks. Next, define a simple learnable mapping x -> y using NetChain with Ramp non-linearities. This effectively gives a piecewise linear model for testFun: regressionNet = NetChain[{5, Ramp, 5, Ramp, 1}] trainingNet = NetChain[{ NetMapOperator[regressionNet], AggregationLayer[Total, 1] }, "Input" -> {"Varying", 1} ]  Train the net and visualize the learned version of testFun: trainedNet = NetTrain[trainingNet, trainingData]; With[{ trainedFun = NetExtract[trainedNet, {1, "Net"}] }, Plot[{testFun[x], trainedFun[x]}, {x, 0, 10}] ]  You may not always get this result, so it may be needed to fiddle around with the training methods etc. Here is an example of how to use NetMapOperator to do this. Define a test function and generate training data from it: testFun = Function[x, Cos[x] + Sqrt[x]]; trainingData = Table[With[{ x = RandomReal[{0, 10}, {RandomInteger[{5, 20}], 1}] }, x -> Total[testFun /@ x] ], 100 ]; Dimensions /@ First[trainingData]  {8, 1} -> {1} As you can see, I'm mapping a n by 1 vector (with n chosen randomly) to a length-1 vector. This is easier to work with inside of the neural networks. Next, define a simple learnable mapping x -> y using NetChain with Ramp non-linearities. This effectively gives a piecewise linear model for testFun: regressionNet = NetChain[{5, Ramp, 5, Ramp, 1}] trainingNet = NetChain[{ NetMapOperator[regressionNet], AggregationLayer[Total, 1] }, "Input" -> {"Varying", 1} ]  Train the net and visualize the learned version of testFun: trainedNet = NetTrain[trainingNet, trainingData]; With[{ trainedFun = NetExtract[trainedNet, {1, "Net"}] }, Plot[{testFun[x], trainedFun[x]}, {x, 0, 10}] ]  You may not always get this result, so it feel free to fiddle around with the training methods etc. 1 answered May 23 at 15:19 Sjoerd Smit 6,5951313 silver badges2727 bronze badges Here is an example of how to use NetMapOperator to do this. Define a test function and generate training data from it: testFun = Function[x, Cos[x] + Sqrt[x]]; trainingData = Table[With[{ x = RandomReal[{0, 10}, {RandomInteger[{5, 20}], 1}] }, x -> Total[testFun /@ x] ], 100 ]; Dimensions /@ First[trainingData]  {8, 1} -> {1} As you can see, I'm mapping a n by 1 vector (with n chosen randomly) to a length-1 vector. This is easier to work with inside of the neural networks. Next, define a simple learnable mapping x -> y using NetChain with Ramp non-linearities. This effectively gives a piecewise linear model for testFun: regressionNet = NetChain[{5, Ramp, 5, Ramp, 1}] trainingNet = NetChain[{ NetMapOperator[regressionNet], AggregationLayer[Total, 1] }, "Input" -> {"Varying", 1} ]  Train the net and visualize the learned version of testFun: trainedNet = NetTrain[trainingNet, trainingData]; With[{ trainedFun = NetExtract[trainedNet, {1, "Net"}] }, Plot[{testFun[x], trainedFun[x]}, {x, 0, 10}] ]  You may not always get this result, so it may be needed to fiddle around with the training methods etc.