use of com.simiacryptus.mindseye.lang.IterativeStopException in project MindsEye by SimiaCryptus.
the class LayerRateDiagnosticTrainer method measure.
/**
* Measure point sample.
*
* @return the point sample
*/
public PointSample measure() {
PointSample currentPoint;
int retries = 0;
do {
if (!subject.reseed(System.nanoTime()) && retries > 0)
throw new IterativeStopException();
if (10 < retries++)
throw new IterativeStopException();
currentPoint = subject.measure(monitor);
} while (!Double.isFinite(currentPoint.sum));
assert Double.isFinite(currentPoint.sum);
return currentPoint;
}
use of com.simiacryptus.mindseye.lang.IterativeStopException in project MindsEye by SimiaCryptus.
the class ValidatingTrainer method reset.
@Nonnull
private ValidatingTrainer reset(@Nonnull final TrainingPhase phase, final long seed) {
if (!phase.trainingSubject.reseed(seed))
throw new IterativeStopException();
phase.orientation.reset();
phase.trainingSubject.reseed(seed);
if (phase.trainingSubject.getLayer() instanceof DAGNetwork) {
((DAGNetwork) phase.trainingSubject.getLayer()).visitLayers(layer -> {
if (layer instanceof StochasticComponent)
((StochasticComponent) layer).shuffle(StochasticComponent.random.get().nextLong());
});
}
return this;
}
use of com.simiacryptus.mindseye.lang.IterativeStopException in project MindsEye by SimiaCryptus.
the class ValidatingTrainer method measure.
private PointSample measure(@Nonnull final TrainingPhase phase) {
int retries = 0;
do {
if (10 < retries++)
throw new IterativeStopException();
final PointSample currentPoint = phase.trainingSubject.measure(monitor);
if (Double.isFinite(currentPoint.getMean()))
return currentPoint;
phase.orientation.reset();
} while (true);
}
use of com.simiacryptus.mindseye.lang.IterativeStopException in project MindsEye by SimiaCryptus.
the class IterativeTrainer method measure.
/**
* Measure point sample.
*
* @param reset the reset
* @return the point sample
*/
@Nullable
public PointSample measure(boolean reset) {
@Nullable PointSample currentPoint = null;
int retries = 0;
do {
if (reset) {
orientation.reset();
if (subject.getLayer() instanceof DAGNetwork) {
((DAGNetwork) subject.getLayer()).visitLayers(layer -> {
if (layer instanceof StochasticComponent)
((StochasticComponent) layer).shuffle(StochasticComponent.random.get().nextLong());
});
}
if (!subject.reseed(System.nanoTime())) {
if (retries > 0)
throw new IterativeStopException("Failed to reset training subject");
} else {
monitor.log(String.format("Reset training subject"));
}
}
if (null != currentPoint) {
currentPoint.freeRef();
}
currentPoint = subject.measure(monitor);
} while (!Double.isFinite(currentPoint.getMean()) && 10 < retries++);
if (!Double.isFinite(currentPoint.getMean())) {
currentPoint.freeRef();
throw new IterativeStopException();
}
return currentPoint;
}
use of com.simiacryptus.mindseye.lang.IterativeStopException in project MindsEye by SimiaCryptus.
the class RoundRobinTrainer method measure.
/**
* Measure point sample.
*
* @return the point sample
*/
public PointSample measure() {
PointSample currentPoint;
int retries = 0;
do {
if (!subject.reseed(System.nanoTime()) && retries > 0)
throw new IterativeStopException();
if (10 < retries++)
throw new IterativeStopException();
currentPoint = subject.measure(monitor);
} while (!Double.isFinite(currentPoint.sum));
assert Double.isFinite(currentPoint.sum);
return currentPoint;
}
Aggregations