Small ConvolutionalIterationListener improvements (#382)

* Add a message to the runtime exception

Signed-off-by: Paul Dubs <paul.dubs@gmail.com>

* Output Convolutions as PNG instead of JPG

A lossless encoding is useful in this case, as it allows small details to be preserved

Signed-off-by: Paul Dubs <paul.dubs@gmail.com>
master
Paul Dubs 2020-04-17 02:19:21 +02:00 committed by GitHub
parent 3d15706ffa
commit bb9cdb251e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 5 additions and 5 deletions

View File

@ -140,7 +140,7 @@ public class ConvolutionalIterationListener extends BaseTrainingListener {
ComputationGraph l = (ComputationGraph) model;
Layer[] layers = l.getLayers();
if(layers.length != activations.size())
throw new RuntimeException();
throw new RuntimeException("layers.length != activations.size(). Got layers.length="+layers.length+", activations.size()="+activations.size());
for( int i=0; i<layers.length; i++ ){
if(layers[i].type() == Layer.Type.CONVOLUTIONAL){
String layerName = layers[i].conf().getLayer().getLayerName();

View File

@ -105,22 +105,22 @@ public class ConvolutionalListenerModule implements UIModule {
BufferedImage bi = clp.getImg();
ByteArrayOutputStream baos = new ByteArrayOutputStream();
try {
ImageIO.write(bi, "jpg", baos);
ImageIO.write(bi, "png", baos);
} catch (IOException e) {
log.warn("Error displaying image", e);
}
rc.response()
.putHeader("content-type", "image/jpg")
.putHeader("content-type", "image/png")
.end(Buffer.buffer(baos.toByteArray()));
} else {
rc.response()
.putHeader("content-type", "image/jpg")
.putHeader("content-type", "image/png")
.end(Buffer.buffer(new byte[0]));
}
} else {
rc.response()
.putHeader("content-type", "image/jpg")
.putHeader("content-type", "image/png")
.end(Buffer.buffer(new byte[0]));
}
}