use of com.simiacryptus.mindseye.layers.cudnn.SumInputsLayer in project MindsEye by SimiaCryptus.
the class StochasticSamplingSubnetLayer method average.
/**
* Average result.
*
* @param samples the samples
* @return the result
*/
public static Result average(final Result[] samples) {
PipelineNetwork gateNetwork = new PipelineNetwork(1);
gateNetwork.wrap(new ProductLayer(), gateNetwork.getInput(0), gateNetwork.wrap(new ValueLayer(new Tensor(1, 1, 1).mapAndFree(v -> 1.0 / samples.length)), new DAGNode[] {}));
SumInputsLayer sumInputsLayer = new SumInputsLayer();
try {
return gateNetwork.evalAndFree(sumInputsLayer.evalAndFree(samples));
} finally {
sumInputsLayer.freeRef();
gateNetwork.freeRef();
}
}
Aggregations