return new FeedForwardToCnnPreProcessor(f.getHeight(), f.getWidth(), f.getDepth()); default: throw new RuntimeException("Unknown input type: " + inputType);
@Override public InputPreProcessor getPreProcessorForInputType(InputType inputType) { switch (inputType.getType()) { case FF: throw new UnsupportedOperationException( "Global max pooling cannot be applied to feed-forward input type. Got input type = " + inputType); case RNN: case CNN: //No preprocessor required return null; case CNNFlat: InputType.InputTypeConvolutionalFlat cFlat = (InputType.InputTypeConvolutionalFlat) inputType; return new FeedForwardToCnnPreProcessor(cFlat.getHeight(), cFlat.getWidth(), cFlat.getDepth()); } return null; }
case CNNFlat: InputType.InputTypeConvolutionalFlat c3 = (InputType.InputTypeConvolutionalFlat) inputType; if (c3.getDepth() != numChannels || c3.getHeight() != inputHeight || c3.getWidth() != inputWidth) { throw new IllegalStateException("Invalid input: Got CNN input type with (d,w,h)=(" + c3.getDepth() + "," + c3.getWidth() + "," + c3.getHeight() + ") but expected (" + numChannels + "," + inputHeight + "," + inputWidth + ")");
@Override public InputType getOutputType(int layerIndex, InputType inputType) { int inH; int inW; int inDepth; if (inputType instanceof InputType.InputTypeConvolutional) { InputType.InputTypeConvolutional conv = (InputType.InputTypeConvolutional) inputType; inH = conv.getHeight(); inW = conv.getWidth(); inDepth = conv.getDepth(); } else if (inputType instanceof InputType.InputTypeConvolutionalFlat) { InputType.InputTypeConvolutionalFlat conv = (InputType.InputTypeConvolutionalFlat) inputType; inH = conv.getHeight(); inW = conv.getWidth(); inDepth = conv.getDepth(); } else { throw new IllegalStateException( "Invalid input type: expected InputTypeConvolutional or InputTypeConvolutionalFlat." + " Got: " + inputType); } int outH = inH + padding[0] + padding[1]; int outW = inW + padding[2] + padding[3]; return InputType.convolutional(outH, outW, inDepth); }
@Override public InputPreProcessor getPreProcessorForInputType(InputType inputType) { if (inputType.getType() == InputType.Type.CNNFlat) { InputType.InputTypeConvolutionalFlat i = (InputType.InputTypeConvolutionalFlat) inputType; return new FeedForwardToCnnPreProcessor(i.getHeight(), i.getWidth(), i.getDepth()); } return null; }