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;
}
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;
}
Aggregations