Search in sources :

Example 6 with ConvolutionLayer

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

the class ObjectLocation method blur.

/**
 * Blur tensor.
 *
 * @param delta1d    the delta 1 d
 * @param iterations the iterations
 * @return the tensor
 */
@Nonnull
public Tensor blur(Tensor delta1d, final int iterations) {
    ConvolutionLayer blur = new ConvolutionLayer(3, 3, 1, 1);
    blur.getKernel().set(0, 1, 1.0);
    blur.getKernel().set(1, 1, 1.0);
    blur.getKernel().set(1, 0, 1.0);
    blur.getKernel().set(1, 2, 1.0);
    blur.getKernel().set(2, 1, 1.0);
    for (int i = 0; i < iterations; i++) {
        delta1d = blur.eval(delta1d).getDataAndFree().getAndFree(0);
    }
    return delta1d;
}
Also used : ConvolutionLayer(com.simiacryptus.mindseye.layers.cudnn.ConvolutionLayer) Nonnull(javax.annotation.Nonnull)

Example 7 with ConvolutionLayer

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

Example 8 with ConvolutionLayer

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

the class VGG16_HDF5 method addConvolutionLayer.

/**
 * Add convolution layer.
 *
 * @param radius         the radius
 * @param inputBands     the input bands
 * @param outputBands    the output bands
 * @param activationMode the activation mode
 * @param hdf_group      the hdf group
 */
protected void addConvolutionLayer(final int radius, final int inputBands, final int outputBands, final ActivationLayer.Mode activationMode, final String hdf_group) {
    add(new ConvolutionLayer(radius, radius, inputBands, outputBands).setPaddingXY(0, 0).setAndFree(hdf5.readDataSet("param_0", hdf_group).permuteDimensionsAndFree(convolutionOrder)));
    add(new ImgBandBiasLayer(outputBands).setAndFree((hdf5.readDataSet("param_1", hdf_group))));
    add(new ActivationLayer(activationMode));
}
Also used : ImgBandBiasLayer(com.simiacryptus.mindseye.layers.cudnn.ImgBandBiasLayer) SoftmaxActivationLayer(com.simiacryptus.mindseye.layers.cudnn.SoftmaxActivationLayer) ActivationLayer(com.simiacryptus.mindseye.layers.cudnn.ActivationLayer) ConvolutionLayer(com.simiacryptus.mindseye.layers.cudnn.ConvolutionLayer)

Example 9 with ConvolutionLayer

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

the class VGG16_HDF5 method phase2b.

/**
 * Phase 2 b.
 */
protected void phase2b() {
    if (large) {
        add(new ImgModulusPaddingLayer(7, 7));
    } else {
        add(new ImgModulusPaddingLayer(-7, -7));
    }
    if (dense) {
        add(new ConvolutionLayer(7, 7, 512, 4096).setStrideXY(1, 1).setPaddingXY(0, 0).setAndFree(hdf5.readDataSet("param_0", "layer_32").reshapeCast(7, 7, 512, 4096).permuteDimensionsAndFree(0, 1, 3, 2)));
    } else {
        add(new ImgModulusPaddingLayer(7, 7));
        add(new ImgReshapeLayer(7, 7, false));
        add(new ConvolutionLayer(1, 1, 25088, 4096).setPaddingXY(0, 0).setAndFree(hdf5.readDataSet("param_0", "layer_32").permuteDimensionsAndFree(fullyconnectedOrder)));
    }
    add(new ImgBandBiasLayer(4096).setAndFree((hdf5.readDataSet("param_1", "layer_32"))));
    add(new ActivationLayer(ActivationLayer.Mode.RELU));
}
Also used : ImgReshapeLayer(com.simiacryptus.mindseye.layers.java.ImgReshapeLayer) ImgBandBiasLayer(com.simiacryptus.mindseye.layers.cudnn.ImgBandBiasLayer) SoftmaxActivationLayer(com.simiacryptus.mindseye.layers.cudnn.SoftmaxActivationLayer) ActivationLayer(com.simiacryptus.mindseye.layers.cudnn.ActivationLayer) ImgModulusPaddingLayer(com.simiacryptus.mindseye.layers.cudnn.ImgModulusPaddingLayer) ConvolutionLayer(com.simiacryptus.mindseye.layers.cudnn.ConvolutionLayer)

Example 10 with ConvolutionLayer

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

the class VGG19_HDF5 method phase2b.

/**
 * Phase 2 b.
 */
protected void phase2b() {
    if (large) {
        add(new ImgModulusPaddingLayer(7, 7));
    } else {
        add(new ImgModulusPaddingLayer(-7, -7));
    }
    if (dense) {
        add(new ConvolutionLayer(7, 7, 512, 4096).setStrideXY(1, 1).setPaddingXY(0, 0).setAndFree(hdf5.readDataSet("param_0", "layer_38").reshapeCast(7, 7, 512, 4096).permuteDimensionsAndFree(0, 1, 3, 2)));
    } else {
        add(new ImgModulusPaddingLayer(7, 7));
        add(new ImgReshapeLayer(7, 7, false));
        add(new ConvolutionLayer(1, 1, 25088, 4096).setPaddingXY(0, 0).setAndFree(hdf5.readDataSet("param_0", "layer_38").permuteDimensionsAndFree(fullyconnectedOrder)));
    }
    add(new ImgBandBiasLayer(4096).setAndFree((hdf5.readDataSet("param_1", "layer_38"))));
    add(new ActivationLayer(ActivationLayer.Mode.RELU));
}
Also used : ImgReshapeLayer(com.simiacryptus.mindseye.layers.java.ImgReshapeLayer) ImgBandBiasLayer(com.simiacryptus.mindseye.layers.cudnn.ImgBandBiasLayer) SoftmaxActivationLayer(com.simiacryptus.mindseye.layers.cudnn.SoftmaxActivationLayer) ActivationLayer(com.simiacryptus.mindseye.layers.cudnn.ActivationLayer) ImgModulusPaddingLayer(com.simiacryptus.mindseye.layers.cudnn.ImgModulusPaddingLayer) ConvolutionLayer(com.simiacryptus.mindseye.layers.cudnn.ConvolutionLayer)

Aggregations

ConvolutionLayer (com.simiacryptus.mindseye.layers.cudnn.ConvolutionLayer)13 ImgBandBiasLayer (com.simiacryptus.mindseye.layers.cudnn.ImgBandBiasLayer)10 ActivationLayer (com.simiacryptus.mindseye.layers.cudnn.ActivationLayer)8 Nonnull (javax.annotation.Nonnull)7 SoftmaxActivationLayer (com.simiacryptus.mindseye.layers.cudnn.SoftmaxActivationLayer)6 Layer (com.simiacryptus.mindseye.lang.Layer)2 ImgModulusPaddingLayer (com.simiacryptus.mindseye.layers.cudnn.ImgModulusPaddingLayer)2 PoolingLayer (com.simiacryptus.mindseye.layers.cudnn.PoolingLayer)2 FullyConnectedLayer (com.simiacryptus.mindseye.layers.java.FullyConnectedLayer)2 ImgReshapeLayer (com.simiacryptus.mindseye.layers.java.ImgReshapeLayer)2 SoftmaxActivationLayer (com.simiacryptus.mindseye.layers.java.SoftmaxActivationLayer)2 BandAvgReducerLayer (com.simiacryptus.mindseye.layers.cudnn.BandAvgReducerLayer)1 GramianLayer (com.simiacryptus.mindseye.layers.cudnn.GramianLayer)1 SquareActivationLayer (com.simiacryptus.mindseye.layers.cudnn.SquareActivationLayer)1 BiasLayer (com.simiacryptus.mindseye.layers.java.BiasLayer)1 ImgBandBiasLayer (com.simiacryptus.mindseye.layers.java.ImgBandBiasLayer)1 ImgCropLayer (com.simiacryptus.mindseye.layers.java.ImgCropLayer)1 ReLuActivationLayer (com.simiacryptus.mindseye.layers.java.ReLuActivationLayer)1 PipelineNetwork (com.simiacryptus.mindseye.network.PipelineNetwork)1 Util (com.simiacryptus.util.Util)1