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
parent
3d15706ffa
commit
bb9cdb251e
|
@ -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();
|
||||
|
|
|
@ -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]));
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue