@Override public InputType getOutputType(int layerIndex, InputType inputType) { if (inputType == null || (inputType.getType() != InputType.Type.FF && inputType.getType() != InputType.Type.CNNFlat)) { throw new IllegalStateException("Invalid input type (layer index = " + layerIndex + ", layer name=\"" + getLayerName() + "\"): expected FeedForward input type. Got: " + inputType); } return InputType.feedForward(nOut); }
@Override public void setNIn(InputType inputType, boolean override) { if (inputType == null || (inputType.getType() != InputType.Type.FF && inputType.getType() != InputType.Type.CNNFlat)) { throw new IllegalStateException("Invalid input type (layer name=\"" + getLayerName() + "\"): expected FeedForward input type. Got: " + inputType); } if (nIn <= 0 || override) { if (inputType.getType() == InputType.Type.FF) { InputType.InputTypeFeedForward f = (InputType.InputTypeFeedForward) inputType; this.nIn = f.getSize(); } else { InputType.InputTypeConvolutionalFlat f = (InputType.InputTypeConvolutionalFlat) inputType; this.nIn = f.getFlattenedSize(); } } }
@Override public InputPreProcessor getPreProcessorForInputType(InputType inputType) { if (inputType == null) { throw new IllegalStateException( "Invalid input for layer (layer name = \"" + getLayerName() + "\"): input type is null"); } switch (inputType.getType()) { case FF: case CNNFlat: //FF -> FF and CNN (flattened format) -> FF: no preprocessor necessary return null; case RNN: //RNN -> FF return new RnnToFeedForwardPreProcessor(); case CNN: //CNN -> FF InputType.InputTypeConvolutional c = (InputType.InputTypeConvolutional) inputType; return new CnnToFeedForwardPreProcessor(c.getHeight(), c.getWidth(), c.getDepth()); default: throw new RuntimeException("Unknown input type: " + inputType); } }