use of com.simiacryptus.mindseye.network.CountingResult in project MindsEye by SimiaCryptus.
the class StochasticSamplingSubnetLayer method eval.
@Nullable
@Override
public Result eval(@Nonnull final Result... inObj) {
Result[] counting = Arrays.stream(inObj).map(r -> {
return new CountingResult(r, samples);
}).toArray(i -> new Result[i]);
return average(Arrays.stream(getSeeds()).mapToObj(seed -> {
Layer inner = getInner();
if (inner instanceof DAGNetwork) {
((DAGNetwork) inner).visitNodes(node -> {
Layer layer = node.getLayer();
if (layer instanceof StochasticComponent) {
((StochasticComponent) layer).shuffle(seed);
}
if (layer instanceof MultiPrecision<?>) {
((MultiPrecision) layer).setPrecision(precision);
}
});
}
if (inner instanceof MultiPrecision<?>) {
((MultiPrecision) inner).setPrecision(precision);
}
if (inner instanceof StochasticComponent) {
((StochasticComponent) inner).shuffle(seed);
}
inner.setFrozen(isFrozen());
return inner.eval(counting);
}).toArray(i -> new Result[i]), precision);
}
Aggregations