@Override public InputType getOutputType(int layerIndex, InputType... vertexInputs) throws InvalidInputTypeException { return InputType.feedForward(1); }
@Override public InputType getOutputType(InputType inputType) { if (inputType == null || inputType.getType() != InputType.Type.RNN) { throw new IllegalStateException("Invalid input: expected input of type RNN, got " + inputType); } InputType.InputTypeRecurrent rnn = (InputType.InputTypeRecurrent) inputType; return InputType.feedForward(rnn.getSize()); }
@Override public InputType getOutputType(int layerIndex, InputType... vertexInputs) throws InvalidInputTypeException { //Infer output shape from specified shape: switch (newShape.length) { case 2: return InputType.feedForward(newShape[1]); case 3: return InputType.recurrent(newShape[1]); case 4: return InputType.convolutional(newShape[1], newShape[2], newShape[0]); //[mb,d,h,w] for activations default: throw new UnsupportedOperationException( "Cannot infer input type for reshape array " + Arrays.toString(newShape)); } }
@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 InputType getOutputType(InputType inputType) { if (inputType == null || inputType.getType() != InputType.Type.CNN) { throw new IllegalStateException("Invalid input type: Expected input of type CNN, got " + inputType); } InputType.InputTypeConvolutional c = (InputType.InputTypeConvolutional) inputType; int outSize = c.getDepth() * c.getHeight() * c.getWidth(); return InputType.feedForward(outSize); }
private InputType[] getInputTypes(DomainDescriptor domainDescriptor) { String[] inputNames = getInputNames(); InputType[] inputTypes = new InputType[inputNames.length]; for (int i = 0; i < inputNames.length; i++) { switch(inputNames[i]) { case "input": inputTypes[i] = InputType.feedForward(domainDescriptor.getNumInputs(inputNames[i])[0]); break; case "indel": case "trueGenotypeInput": inputTypes[i] = InputType.recurrent(domainDescriptor.getNumInputs(inputNames[i])[0]); break; default: throw new RuntimeException("Invalid input to computation graph"); } } return inputTypes; }
if (collapseDimensions) { return InputType.feedForward(recurrent.getSize()); } else { InputType.InputTypeConvolutional conv = (InputType.InputTypeConvolutional) inputType; if (collapseDimensions) { return InputType.feedForward(conv.getDepth()); } else { return InputType.convolutional(1, 1, conv.getDepth()); InputType.InputTypeConvolutionalFlat convFlat = (InputType.InputTypeConvolutionalFlat) inputType; if (collapseDimensions) { return InputType.feedForward(convFlat.getDepth()); } else { return InputType.convolutional(1, 1, convFlat.getDepth());
@Override public InputType getOutputType(int layerIndex, InputType... vertexInputs) throws InvalidInputTypeException { if (vertexInputs.length != 1) throw new InvalidInputTypeException("Invalid input type: cannot get last time step of more than 1 input"); if (vertexInputs[0].getType() != InputType.Type.RNN) { throw new InvalidInputTypeException( "Invalid input type: cannot get subset of non RNN input (got: " + vertexInputs[0] + ")"); } return InputType.feedForward(((InputType.InputTypeRecurrent) vertexInputs[0]).getSize()); }
private InputType[] getInputTypes(DomainDescriptor domainDescriptor) { String[] inputNames = getInputNames(); InputType[] inputTypes = new InputType[inputNames.length]; for (int i = 0; i < inputNames.length; i++) { switch (inputNames[i]) { case "input": inputTypes[i] = InputType.feedForward(domainDescriptor.getNumInputs(inputNames[i])[0]); break; case "from": case "G1": case "G2": case "G3": case "trueGenotypeInput": inputTypes[i] = InputType.recurrent(domainDescriptor.getNumInputs(inputNames[i])[0]); break; default: throw new RuntimeException("Invalid input to computation graph"); } } return inputTypes; }
public static InputType inferInputType(INDArray inputArray) { //Note: ConvolutionalFlat and FeedForward look identical... but either should work OK if using something // like FeedForwardToCnnPreProcessor switch (inputArray.rank()) { case 2: return InputType.feedForward(inputArray.size(1)); case 3: return InputType.recurrent(inputArray.size(1), inputArray.size(2)); case 4: //Order: [minibatch, depth, height, width] -> [h, w, d] return InputType.convolutional(inputArray.size(2), inputArray.size(3), inputArray.size(1)); default: throw new IllegalArgumentException( "Cannot infer input type for array with shape: " + Arrays.toString(inputArray.shape())); } }
@Override public InputType getOutputType(int layerIndex, InputType... vertexInputs) throws InvalidInputTypeException { if (vertexInputs.length != 1) { throw new InvalidInputTypeException( "SubsetVertex expects single input type. Received: " + Arrays.toString(vertexInputs)); } switch (vertexInputs[0].getType()) { case FF: return InputType.feedForward(to - from + 1); case RNN: return InputType.recurrent(to - from + 1); case CNN: InputType.InputTypeConvolutional conv = (InputType.InputTypeConvolutional) vertexInputs[0]; int depth = conv.getDepth(); if (to >= depth) { throw new InvalidInputTypeException("Invalid range: Cannot select depth subset [" + from + "," + to + "] inclusive from CNN activations with " + " [depth,width,height] = [" + depth + "," + conv.getWidth() + "," + conv.getHeight() + "]"); } return InputType.convolutional(conv.getHeight(), conv.getWidth(), from - to + 1); case CNNFlat: //TODO work out how to do this - could be difficult... throw new UnsupportedOperationException( "Subsetting data in flattened convolutional format not yet supported"); default: throw new RuntimeException("Unknown input type: " + vertexInputs[0]); } }
int nIn = ffl.getNIn(); if (nIn > 0) { inputType = InputType.feedForward(nIn);
return InputType.feedForward(size); else return InputType.recurrent(size); return InputType.feedForward(-1); else return InputType.recurrent(-1);
return InputType.feedForward(size); else return InputType.recurrent(size); return InputType.feedForward(-1); else return InputType.recurrent(-1);
return InputType.feedForward(size); else return InputType.recurrent(size, tsLength); return InputType.feedForward(-1); else return InputType.recurrent(-1, tsLength);
return InputType.feedForward(size); } else { int tsLength = ((InputType.InputTypeRecurrent) vertexInputs[0]).getTimeSeriesLength(); return InputType.feedForward(-1); } else { int tsLength = ((InputType.InputTypeRecurrent) vertexInputs[0]).getTimeSeriesLength();