Class TransferLearning.GraphBuilder

    • Constructor Detail

      • GraphBuilder

        public GraphBuilder​(ComputationGraph origGraph)
        Computation Graph to tweak for transfer learning
        Parameters:
        origGraph -
    • Method Detail

      • fineTuneConfiguration

        public TransferLearning.GraphBuilder fineTuneConfiguration​(FineTuneConfiguration fineTuneConfiguration)
        Set parameters to selectively override existing learning parameters Usage eg. specify a lower learning rate. This will get applied to all layers
        Parameters:
        fineTuneConfiguration -
        Returns:
        GraphBuilder
      • setFeatureExtractor

        public TransferLearning.GraphBuilder setFeatureExtractor​(String... layerName)
        Specify a layer vertex to set as a "feature extractor" The specified layer vertex and the layers on the path from an input vertex to it will be "frozen" with parameters staying constant
        Parameters:
        layerName -
        Returns:
        Builder
      • nOutReplace

        public TransferLearning.GraphBuilder nOutReplace​(String layerName,
                                                         int nOut,
                                                         WeightInit scheme)
        Modify the architecture of a vertex layer by changing nOut Note this will also affect the vertex layer that follows the layer specified, unless it is the output layer Currently does not support modifying nOut of layers that feed into non-layer vertices like merge, subset etc To modify nOut for such vertices use remove vertex, followed by add vertex Can specify different weight init schemes for the specified layer and the layer that follows it.
        Parameters:
        layerName - The name of the layer to change nOut of
        nOut - Value of nOut to change to
        scheme - Weight init scheme to use for params in layerName and the layers following it
        Returns:
        GraphBuilder
        See Also:
        DISTRIBUTION
      • nOutReplace

        public TransferLearning.GraphBuilder nOutReplace​(String layerName,
                                                         int nOut,
                                                         Distribution dist)
        Modify the architecture of a vertex layer by changing nOut Note this will also affect the vertex layer that follows the layer specified, unless it is the output layer Currently does not support modifying nOut of layers that feed into non-layer vertices like merge, subset etc To modify nOut for such vertices use remove vertex, followed by add vertex Can specify different weight init schemes for the specified layer and the layer that follows it.
        Parameters:
        layerName - The name of the layer to change nOut of
        nOut - Value of nOut to change to
        dist - Weight distribution scheme to use
        Returns:
        GraphBuilder
        See Also:
        DISTRIBUTION
      • nOutReplace

        public TransferLearning.GraphBuilder nOutReplace​(String layerName,
                                                         int nOut,
                                                         Distribution dist,
                                                         Distribution distNext)
        Modified nOut of specified layer. Also affects layers following layerName unless they are output layers
        Parameters:
        layerName - The name of the layer to change nOut of
        nOut - Value of nOut to change to
        dist - Weight distribution scheme to use for layerName
        distNext - Weight distribution scheme for layers following layerName
        Returns:
        GraphBuilder
        See Also:
        DISTRIBUTION
      • nInReplace

        public TransferLearning.GraphBuilder nInReplace​(String layerName,
                                                        int nIn,
                                                        WeightInit scheme)
        Modify the architecture of a vertex layer by changing nIn of the specified layer.
        Note that only the specified layer will be modified - all other layers will not be changed by this call.
        Parameters:
        layerName - The name of the layer to change nIn of
        nIn - Value of nIn to change to
        scheme - Weight init scheme to use for params in layerName
        Returns:
        GraphBuilder
      • nInReplace

        public TransferLearning.GraphBuilder nInReplace​(String layerName,
                                                        int nIn,
                                                        WeightInit scheme,
                                                        Distribution dist)
        Modify the architecture of a vertex layer by changing nIn of the specified layer.
        Note that only the specified layer will be modified - all other layers will not be changed by this call.
        Parameters:
        layerName - The name of the layer to change nIn of
        nIn - Value of nIn to change to
        scheme - Weight init scheme to use for params in layerName and the layers following it
        Returns:
        GraphBuilder
      • nInReplace

        public TransferLearning.GraphBuilder nInReplace​(String layerName,
                                                        int nIn,
                                                        IWeightInit scheme)
        Modify the architecture of a vertex layer by changing nIn of the specified layer.
        Note that only the specified layer will be modified - all other layers will not be changed by this call.
        Parameters:
        layerName - The name of the layer to change nIn of
        nIn - Value of nIn to change to
        scheme - Weight init scheme to use for params in layerName and the layers following it
        Returns:
        GraphBuilder
      • removeVertexKeepConnections

        public TransferLearning.GraphBuilder removeVertexKeepConnections​(String outputName)
        Remove the specified vertex from the computation graph but keep it's connections. Note the expectation here is to then add back another vertex with the same name or else the graph will be left in an invalid state Possibly with references to vertices that no longer exist
        Parameters:
        outputName -
        Returns:
      • removeVertexAndConnections

        public TransferLearning.GraphBuilder removeVertexAndConnections​(String vertexName)
        Remove specified vertex and it's connections from the computation graph
        Parameters:
        vertexName -
        Returns:
      • addLayer

        public TransferLearning.GraphBuilder addLayer​(String layerName,
                                                      Layer layer,
                                                      String... layerInputs)
        Add a layer of the specified configuration to the computation graph
        Parameters:
        layerName -
        layer -
        layerInputs -
        Returns:
      • setOutputs

        public TransferLearning.GraphBuilder setOutputs​(String... outputNames)
        Set outputs to the computation graph, will add to ones that are existing Also determines the order, like in ComputationGraphConfiguration
        Parameters:
        outputNames -
        Returns:
      • setInputs

        public TransferLearning.GraphBuilder setInputs​(String... inputs)
        Sets new inputs for the computation graph. This method will remove any pre-existing inputs.
        Parameters:
        inputs - String names of each graph input.
        Returns:
        GraphBuilder instance.
      • setInputTypes

        public TransferLearning.GraphBuilder setInputTypes​(InputType... inputTypes)
        Sets the input type of corresponding inputs.
        Parameters:
        inputTypes - The type of input (such as convolutional).
        Returns:
        GraphBuilder instance.
      • build

        public ComputationGraph build()
        Returns a computation graph build to specifications. Init has been internally called. Can be fit directly.
        Returns:
        Computation graph