Search in sources :

Example 1 with SquareActivationLayer

use of com.simiacryptus.mindseye.layers.cudnn.SquareActivationLayer in project MindsEye by SimiaCryptus.

the class DeepDream method getContentComponents.

/**
 * Gets content components.
 *
 * @param setup   the setup
 * @param nodeMap the node map
 * @return the content components
 */
@Nonnull
public ArrayList<Tuple2<Double, DAGNode>> getContentComponents(NeuralSetup<T> setup, final Map<T, DAGNode> nodeMap) {
    ArrayList<Tuple2<Double, DAGNode>> contentComponents = new ArrayList<>();
    for (final T layerType : getLayerTypes()) {
        final DAGNode node = nodeMap.get(layerType);
        if (setup.style.coefficients.containsKey(layerType)) {
            final double coeff_content = setup.style.coefficients.get(layerType).rms;
            DAGNetwork network = node.getNetwork();
            contentComponents.add(new Tuple2<>(coeff_content, network.wrap(new MeanSqLossLayer(), node, network.wrap(new ValueLayer(setup.contentTarget.content.get(layerType))))));
            final double coeff_gain = setup.style.coefficients.get(layerType).gain;
            contentComponents.add(new Tuple2<>(-coeff_gain, network.wrap(new AvgReducerLayer(), network.wrap(new SquareActivationLayer(), node))));
        }
    }
    return contentComponents;
}
Also used : Tuple2(com.simiacryptus.util.lang.Tuple2) AvgReducerLayer(com.simiacryptus.mindseye.layers.cudnn.AvgReducerLayer) ArrayList(java.util.ArrayList) ValueLayer(com.simiacryptus.mindseye.layers.cudnn.ValueLayer) SquareActivationLayer(com.simiacryptus.mindseye.layers.cudnn.SquareActivationLayer) DAGNetwork(com.simiacryptus.mindseye.network.DAGNetwork) DAGNode(com.simiacryptus.mindseye.network.DAGNode) MeanSqLossLayer(com.simiacryptus.mindseye.layers.cudnn.MeanSqLossLayer) Nonnull(javax.annotation.Nonnull)

Example 2 with SquareActivationLayer

use of com.simiacryptus.mindseye.layers.cudnn.SquareActivationLayer in project MindsEye by SimiaCryptus.

the class ArtistryUtil method squareAvg.

/**
 * Square avg pipeline network.
 *
 * @param network      the network
 * @param mean         the mean
 * @param pcaTransform the pca transform
 * @return the pipeline network
 */
@Nonnull
public static PipelineNetwork squareAvg(final PipelineNetwork network, Tensor mean, Tensor pcaTransform) {
    int[] dimensions = pcaTransform.getDimensions();
    int inputBands = mean.getDimensions()[2];
    int pcaBands = dimensions[2];
    int outputBands = pcaBands / inputBands;
    int width = dimensions[0];
    int height = dimensions[1];
    network.wrap(new ImgBandBiasLayer(mean.scale(-1)));
    network.wrap(new ConvolutionLayer(width, height, inputBands, outputBands).set(pcaTransform));
    network.wrap(new SquareActivationLayer());
    network.wrap(new BandAvgReducerLayer());
    return network;
}
Also used : ImgBandBiasLayer(com.simiacryptus.mindseye.layers.cudnn.ImgBandBiasLayer) SquareActivationLayer(com.simiacryptus.mindseye.layers.cudnn.SquareActivationLayer) BandAvgReducerLayer(com.simiacryptus.mindseye.layers.cudnn.BandAvgReducerLayer) ConvolutionLayer(com.simiacryptus.mindseye.layers.cudnn.ConvolutionLayer) Nonnull(javax.annotation.Nonnull)

Aggregations

SquareActivationLayer (com.simiacryptus.mindseye.layers.cudnn.SquareActivationLayer)2 Nonnull (javax.annotation.Nonnull)2 AvgReducerLayer (com.simiacryptus.mindseye.layers.cudnn.AvgReducerLayer)1 BandAvgReducerLayer (com.simiacryptus.mindseye.layers.cudnn.BandAvgReducerLayer)1 ConvolutionLayer (com.simiacryptus.mindseye.layers.cudnn.ConvolutionLayer)1 ImgBandBiasLayer (com.simiacryptus.mindseye.layers.cudnn.ImgBandBiasLayer)1 MeanSqLossLayer (com.simiacryptus.mindseye.layers.cudnn.MeanSqLossLayer)1 ValueLayer (com.simiacryptus.mindseye.layers.cudnn.ValueLayer)1 DAGNetwork (com.simiacryptus.mindseye.network.DAGNetwork)1 DAGNode (com.simiacryptus.mindseye.network.DAGNode)1 Tuple2 (com.simiacryptus.util.lang.Tuple2)1 ArrayList (java.util.ArrayList)1