use of com.simiacryptus.mindseye.layers.cudnn.ProductLayer in project MindsEye by SimiaCryptus.
the class StochasticSamplingSubnetLayerTest method getLayer.
@Nonnull
@Override
public Layer getLayer(final int[][] inputSize, Random random) {
PipelineNetwork subnetwork = new PipelineNetwork(1);
subnetwork.wrap(new ProductLayer(), subnetwork.getInput(0), subnetwork.add(new StochasticBinaryNoiseLayer(0.5, 1.0, inputSize[0]), new DAGNode[] {}));
StochasticSamplingSubnetLayer tileSubnetLayer = new StochasticSamplingSubnetLayer(subnetwork, 2);
subnetwork.freeRef();
return tileSubnetLayer;
}
use of com.simiacryptus.mindseye.layers.cudnn.ProductLayer 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