use of com.simiacryptus.mindseye.network.PipelineNetwork in project MindsEye by SimiaCryptus.
the class BinarySumLayer method getCompatibilityLayer.
/**
* Gets compatibility layer.
*
* @return the compatibility layer
*/
@Nonnull
public Layer getCompatibilityLayer() {
@Nonnull PipelineNetwork network = new PipelineNetwork(2);
network.wrap(new SumInputsLayer(), network.wrap(new LinearActivationLayer().setScale(this.leftFactor).freeze(), network.getInput(0)), network.wrap(new LinearActivationLayer().setScale(this.rightFactor).freeze(), network.getInput(1)));
return network;
}
use of com.simiacryptus.mindseye.network.PipelineNetwork in project MindsEye by SimiaCryptus.
the class ExplodedConvolutionGrid method getNetwork.
/**
* Gets network.
*
* @return the network
*/
@Nonnull
public PipelineNetwork getNetwork() {
assertAlive();
@Nonnull PipelineNetwork network = new PipelineNetwork(1);
add(network.getInput(0));
return network;
}
use of com.simiacryptus.mindseye.network.PipelineNetwork in project MindsEye by SimiaCryptus.
the class MnistTestBase method buildModel.
/**
* Build model dag network.
*
* @param log the log
* @return the dag network
*/
public DAGNetwork buildModel(@Nonnull final NotebookOutput log) {
log.h1("Model");
log.p("This is a very simple model that performs basic logistic regression. " + "It is expected to be trainable to about 91% accuracy on MNIST.");
return log.code(() -> {
@Nonnull final PipelineNetwork network = new PipelineNetwork();
network.add(new BiasLayer(28, 28, 1));
network.add(new FullyConnectedLayer(new int[] { 28, 28, 1 }, new int[] { 10 }).set(() -> 0.001 * (Math.random() - 0.45)));
network.add(new SoftmaxActivationLayer());
return network;
});
}
use of com.simiacryptus.mindseye.network.PipelineNetwork in project MindsEye by SimiaCryptus.
the class EncodingUtil method buildTrainingModel.
/**
* Build training model dag network.
*
* @param innerModel the heapCopy model
* @param reproducedColumn the reproduced column
* @param learnedColumn the learned column
* @return the dag network
*/
@Nonnull
public static DAGNetwork buildTrainingModel(final Layer innerModel, final int reproducedColumn, final int learnedColumn) {
@Nonnull final PipelineNetwork network = new PipelineNetwork(Math.max(learnedColumn, reproducedColumn) + 1);
// network.add(new NthPowerActivationLayer().setPower(0.5), );
network.wrap(new MeanSqLossLayer(), network.add("image", innerModel, network.getInput(learnedColumn)), network.getInput(reproducedColumn));
// addLogging(network);
return network;
}
use of com.simiacryptus.mindseye.network.PipelineNetwork in project MindsEye by SimiaCryptus.
the class EncodingUtil method renderLayer.
/**
* Render layer.
*
* @param log the log
* @param dataPipeline the data pipeline
* @param row the row
* @param col the col
* @param tensor the tensor
*/
public static void renderLayer(@Nonnull final NotebookOutput log, @Nonnull final List<Layer> dataPipeline, @Nonnull final LinkedHashMap<CharSequence, Object> row, final int col, @Nonnull final Tensor tensor) {
row.put("Data_" + col, TestUtil.render(log, tensor, 0 < col));
if (dataPipeline.size() >= col - 1 && 1 < col) {
@Nonnull final PipelineNetwork decoder = new PipelineNetwork();
for (int i = col - 2; i >= 0; i--) {
decoder.add(dataPipeline.get(i));
}
@Nullable final Tensor decoded = decoder.eval(tensor).getData().get(0);
row.put("Decode_" + col, TestUtil.render(log, decoded, false));
final List<Tensor> rawComponents = IntStream.range(0, tensor.getDimensions()[2]).mapToObj(band -> EncodingUtil.findUnitComponent(decoder, band, tensor)).collect(Collectors.toList());
@Nullable final Tensor baseline = EncodingUtil.findBaseline(decoder, tensor);
final List<Tensor> signedComponents = IntStream.range(0, tensor.getDimensions()[2]).mapToObj(band -> rawComponents.get(band).minus(baseline)).collect(Collectors.toList());
row.put("SVG_" + col, log.file(EncodingUtil.decompositionSvg(log, baseline, signedComponents), "svg" + EncodingUtil.svgNumber++ + ".svg", "SVG Composite Image"));
row.put("GIF_" + col, EncodingUtil.animatedGif(log, baseline, signedComponents));
@Nonnull final CharSequence render = signedComponents.stream().map(signedContribution -> TestUtil.render(log, signedContribution, true)).reduce((a, b) -> a + "" + b).get();
row.put("Band_Decode_" + col, render);
}
}
Aggregations