Search in sources :

Example 1 with ImgBandScaleLayer

use of com.simiacryptus.mindseye.layers.java.ImgBandScaleLayer in project MindsEye by SimiaCryptus.

the class EncodingUtil method findUnitComponent.

/**
 * Find unit component tensor.
 *
 * @param decoder the decoder
 * @param band    the band
 * @param tensor  the tensor
 * @return the tensor
 */
@Nullable
public static Tensor findUnitComponent(final PipelineNetwork decoder, final int band, @Nonnull final Tensor tensor) {
    @Nonnull final PipelineNetwork decoderBand = new PipelineNetwork();
    @Nonnull final double[] gate = new double[tensor.getDimensions()[2]];
    gate[band] = 1;
    decoderBand.add(new ImgBandScaleLayer(gate));
    decoderBand.add(decoder);
    try {
        return decoderBand.eval(tensor).getData().get(0);
    // return log.image(t.toImage(), "");
    } catch (@Nonnull final RuntimeException e) {
        throw e;
    } catch (@Nonnull final Exception e) {
        throw new RuntimeException(e);
    }
}
Also used : Nonnull(javax.annotation.Nonnull) PipelineNetwork(com.simiacryptus.mindseye.network.PipelineNetwork) ImgBandScaleLayer(com.simiacryptus.mindseye.layers.java.ImgBandScaleLayer) IOException(java.io.IOException) Nullable(javax.annotation.Nullable)

Aggregations

ImgBandScaleLayer (com.simiacryptus.mindseye.layers.java.ImgBandScaleLayer)1 PipelineNetwork (com.simiacryptus.mindseye.network.PipelineNetwork)1 IOException (java.io.IOException)1 Nonnull (javax.annotation.Nonnull)1 Nullable (javax.annotation.Nullable)1