use of com.simiacryptus.mindseye.network.PipelineNetwork in project MindsEye by SimiaCryptus.
the class EncodingUtil method downExplodeTensors.
/**
* Down explode tensors stream.
*
* @param stream the stream
* @param factor the factor
* @return the stream
*/
@Nonnull
public static Stream<Tensor[]> downExplodeTensors(@Nonnull final Stream<Tensor[]> stream, final int factor) {
if (0 >= factor)
throw new IllegalArgumentException();
if (-1 == factor)
throw new IllegalArgumentException();
return 1 == factor ? stream : stream.flatMap(tensor -> IntStream.range(0, factor * factor).mapToObj(subband -> {
@Nonnull final int[] select = new int[tensor[1].getDimensions()[2]];
final int offset = subband * select.length;
for (int i = 0; i < select.length; i++) {
select[i] = offset + i;
}
@Nonnull final PipelineNetwork network = new PipelineNetwork();
network.add(new ImgReshapeLayer(factor, factor, false));
network.add(new ImgBandSelectLayer(select));
@Nullable final Tensor result = network.eval(tensor[1]).getData().get(0);
return new Tensor[] { tensor[0], result };
}));
}
use of com.simiacryptus.mindseye.network.PipelineNetwork in project MindsEye by SimiaCryptus.
the class RecursiveSubspaceTest method buildModel.
@Override
public DAGNetwork buildModel(@Nonnull NotebookOutput log) {
log.h3("Model");
log.p("We use a multi-level convolution network");
return log.code(() -> {
@Nonnull final PipelineNetwork network = new PipelineNetwork();
double weight = 1e-3;
@Nonnull DoubleSupplier init = () -> weight * (Math.random() - 0.5);
network.add(new ConvolutionLayer(3, 3, 1, 5).set(init));
network.add(new ImgBandBiasLayer(5));
network.add(new PoolingLayer().setMode(PoolingLayer.PoolingMode.Max));
network.add(new ActivationLayer(ActivationLayer.Mode.RELU));
network.add(newNormalizationLayer());
network.add(new ConvolutionLayer(3, 3, 5, 5).set(init));
network.add(new ImgBandBiasLayer(5));
network.add(new PoolingLayer().setMode(PoolingLayer.PoolingMode.Max));
network.add(new ActivationLayer(ActivationLayer.Mode.RELU));
network.add(newNormalizationLayer());
network.add(new BiasLayer(7, 7, 5));
network.add(new FullyConnectedLayer(new int[] { 7, 7, 5 }, new int[] { 10 }).set(init));
network.add(new SoftmaxActivationLayer());
return network;
});
}
use of com.simiacryptus.mindseye.network.PipelineNetwork 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.network.PipelineNetwork in project MindsEye by SimiaCryptus.
the class ArtistryUtil method withClamp.
/**
* With clamp pipeline network.
*
* @param network1 the network 1
* @return the pipeline network
*/
@Nonnull
public static PipelineNetwork withClamp(final PipelineNetwork network1) {
PipelineNetwork network = new PipelineNetwork(1);
network.wrap(getClamp(255));
network.wrap(network1);
return network;
}
use of com.simiacryptus.mindseye.network.PipelineNetwork in project MindsEye by SimiaCryptus.
the class DeepDream method fitnessNetwork.
/**
* Fitness function pipeline network.
*
* @param setup the setup
* @return the pipeline network
*/
@Nonnull
public PipelineNetwork fitnessNetwork(NeuralSetup setup) {
PipelineNetwork pipelineNetwork = getInstance().getNetwork();
Map<T, DAGNode> nodes = new HashMap<>();
Map<T, UUID> ids = getInstance().getNodes();
ids.forEach((l, id) -> nodes.put(l, pipelineNetwork.getChildNode(id)));
PipelineNetwork network = processStats(setup, nodes, pipelineNetwork);
// network = withClamp(network);
ArtistryUtil.setPrecision(network, setup.style.precision);
return network;
}
Aggregations