Search in sources :

Example 1 with AvgReducerLayer

use of com.simiacryptus.mindseye.layers.cudnn.AvgReducerLayer 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)

Aggregations

AvgReducerLayer (com.simiacryptus.mindseye.layers.cudnn.AvgReducerLayer)1 MeanSqLossLayer (com.simiacryptus.mindseye.layers.cudnn.MeanSqLossLayer)1 SquareActivationLayer (com.simiacryptus.mindseye.layers.cudnn.SquareActivationLayer)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 Nonnull (javax.annotation.Nonnull)1