src/demo/TSP.java
public NeuralNetwork buildNeuralNetwork(int inputSize, int outputSize) throws DynamicParamException, NeuralNetworkException, MatrixException {
        NeuralNetwork neuralNetwork = new NeuralNetwork();
        neuralNetwork.addInputLayer("width = " + inputSize);
        String width = "width = " + (6 * inputSize);
        neuralNetwork.addHiddenLayer(LayerType.FEEDFORWARD, new ActivationFunction(UnaryFunctionType.RELU), width);
        neuralNetwork.addHiddenLayer(LayerType.FEEDFORWARD, new ActivationFunction(UnaryFunctionType.RELU), width);
        neuralNetwork.addHiddenLayer(LayerType.FEEDFORWARD, new ActivationFunction(UnaryFunctionType.RELU), "width = " + (1 + outputSize) + ", splitOutputAtPosition = 1");
        neuralNetwork.addOutputLayer(new BinaryFunctionType[] {BinaryFunctionType.MEAN_SQUARED_ERROR,BinaryFunctionType.DIRECT_GRADIENT});
        neuralNetwork.build();
        neuralNetwork.setOptimizer(OptimizationType.RADAM);
        neuralNetwork.verboseTraining(10);
        return neuralNetwork;
    }
/**
     * Build neural network for travelling salesman (agent).
     *
     * @param inputSize input size of neural network (number of states)
     * @param outputSize output size of neural network (number of actions and their values).
     * @return built neural network
     * @throws DynamicParamException throws exception if setting of dynamic parameters fails.
     * @throws NeuralNetworkException throws exception if building of neural network fails.
     * @throws MatrixException throws exception if custom function is attempted to be created with this constructor.
     */
Build neural network for travelling salesman (agent).
@param inputSize input size of neural network (number of states)
@param outputSize output size of neural network (number of actions and their values).
@return built neural network
@throws DynamicParamException throws exception if setting of dynamic parameters fails.
@throws NeuralNetworkException throws exception if building of neural network fails.
@throws MatrixException throws exception if custom function is attempted to be created with this constructor.
Build neural network for travelling salesman ( agent ) . @param inputSize input size of neural network ( number of states ) @param outputSize output size of neural network ( number of actions and their values ) . @return built neural network @throws DynamicParamException throws exception if setting of dynamic parameters fails . @throws NeuralNetworkException throws exception if building of neural network fails . @throws MatrixException throws exception if custom function is attempted to be created with this constructor .
public NeuralNetwork buildNeuralNetwork(int inputSize, int outputSize) throws DynamicParamException, NeuralNetworkException, MatrixException {
        NeuralNetwork neuralNetwork = new NeuralNetwork();
        neuralNetwork.addInputLayer("width = " + inputSize);
        String width = "width = " + (6 * inputSize);
        neuralNetwork.addHiddenLayer(LayerType.FEEDFORWARD, new ActivationFunction(UnaryFunctionType.RELU), width);
        neuralNetwork.addHiddenLayer(LayerType.FEEDFORWARD, new ActivationFunction(UnaryFunctionType.RELU), width);
        neuralNetwork.addHiddenLayer(LayerType.FEEDFORWARD, new ActivationFunction(UnaryFunctionType.RELU), "width = " + (1 + outputSize) + ", splitOutputAtPosition = 1");
        neuralNetwork.addOutputLayer(new BinaryFunctionType[] {BinaryFunctionType.MEAN_SQUARED_ERROR,BinaryFunctionType.DIRECT_GRADIENT});
        neuralNetwork.build();
        neuralNetwork.setOptimizer(OptimizationType.RADAM);
        neuralNetwork.verboseTraining(10);
        return neuralNetwork;
    }
public NeuralNetwork buildNeuralNetwork ( int inputSize , int outputSize ) throws DynamicParamException , NeuralNetworkException , MatrixException { NeuralNetwork neuralNetwork = new NeuralNetwork ( ) ; neuralNetwork . addInputLayer ( "width = " + inputSize ) ; String width = "width = " + ( 6 * inputSize ) ; neuralNetwork . addHiddenLayer ( LayerType . FEEDFORWARD , new ActivationFunction ( UnaryFunctionType . RELU ) , width ) ; neuralNetwork . addHiddenLayer ( LayerType . FEEDFORWARD , new ActivationFunction ( UnaryFunctionType . RELU ) , width ) ; neuralNetwork . addHiddenLayer ( LayerType . FEEDFORWARD , new ActivationFunction ( UnaryFunctionType . RELU ) , "width = " + ( 1 + outputSize ) + ", splitOutputAtPosition = 1" ) ; neuralNetwork . addOutputLayer ( new BinaryFunctionType [ ] { BinaryFunctionType . MEAN_SQUARED_ERROR , BinaryFunctionType . DIRECT_GRADIENT } ) ; neuralNetwork . build ( ) ; neuralNetwork . setOptimizer ( OptimizationType . RADAM ) ; neuralNetwork . verboseTraining ( 10 ) ; return neuralNetwork ; }
Build neural network for travelling salesman (agent).
Build neural network for travelling salesman ( agent ) .