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