src/demo/TicTacToe.java
public NeuralNetwork buildNeuralNetwork(int inputSize, int outputSize, boolean policyGradient, boolean stateValue) throws DynamicParamException, NeuralNetworkException, MatrixException {
        NeuralNetwork neuralNetwork = new NeuralNetwork();
        neuralNetwork.addInputLayer("width = " + inputSize);
        neuralNetwork.addHiddenLayer(LayerType.FEEDFORWARD, new ActivationFunction(UnaryFunctionType.RELU), "width = 100");
        neuralNetwork.addHiddenLayer(LayerType.FEEDFORWARD, new ActivationFunction(UnaryFunctionType.RELU), "width = 100");
        neuralNetwork.addHiddenLayer(LayerType.FEEDFORWARD, new ActivationFunction(UnaryFunctionType.RELU), "width = " + (outputSize + (!policyGradient ? (stateValue ? 1 : 0) : 0)));
        neuralNetwork.addOutputLayer(!policyGradient ? BinaryFunctionType.MEAN_SQUARED_ERROR : BinaryFunctionType.DIRECT_GRADIENT);
        neuralNetwork.build();
        neuralNetwork.setOptimizer(OptimizationType.ADAM);
        if (!policyGradient) neuralNetwork.verboseTraining(100);
        neuralNetwork.setNeuralNetworkName("TicTacToe");
        return neuralNetwork;
    }
/**
     * Builds neural network for tic tac toe player (agent).
     *
     * @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.
     */
Builds neural network for tic tac toe player (agent).
@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.
Builds neural network for tic tac toe player ( agent ) . @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, boolean policyGradient, boolean stateValue) throws DynamicParamException, NeuralNetworkException, MatrixException {
        NeuralNetwork neuralNetwork = new NeuralNetwork();
        neuralNetwork.addInputLayer("width = " + inputSize);
        neuralNetwork.addHiddenLayer(LayerType.FEEDFORWARD, new ActivationFunction(UnaryFunctionType.RELU), "width = 100");
        neuralNetwork.addHiddenLayer(LayerType.FEEDFORWARD, new ActivationFunction(UnaryFunctionType.RELU), "width = 100");
        neuralNetwork.addHiddenLayer(LayerType.FEEDFORWARD, new ActivationFunction(UnaryFunctionType.RELU), "width = " + (outputSize + (!policyGradient ? (stateValue ? 1 : 0) : 0)));
        neuralNetwork.addOutputLayer(!policyGradient ? BinaryFunctionType.MEAN_SQUARED_ERROR : BinaryFunctionType.DIRECT_GRADIENT);
        neuralNetwork.build();
        neuralNetwork.setOptimizer(OptimizationType.ADAM);
        if (!policyGradient) neuralNetwork.verboseTraining(100);
        neuralNetwork.setNeuralNetworkName("TicTacToe");
        return neuralNetwork;
    }
public NeuralNetwork buildNeuralNetwork ( int inputSize , int outputSize , boolean policyGradient , boolean stateValue ) throws DynamicParamException , NeuralNetworkException , MatrixException { NeuralNetwork neuralNetwork = new NeuralNetwork ( ) ; neuralNetwork . addInputLayer ( "width = " + inputSize ) ; neuralNetwork . addHiddenLayer ( LayerType . FEEDFORWARD , new ActivationFunction ( UnaryFunctionType . RELU ) , "width = 100" ) ; neuralNetwork . addHiddenLayer ( LayerType . FEEDFORWARD , new ActivationFunction ( UnaryFunctionType . RELU ) , "width = 100" ) ; neuralNetwork . addHiddenLayer ( LayerType . FEEDFORWARD , new ActivationFunction ( UnaryFunctionType . RELU ) , "width = " + ( outputSize + ( ! policyGradient ? ( stateValue ? 1 : 0 ) : 0 ) ) ) ; neuralNetwork . addOutputLayer ( ! policyGradient ? BinaryFunctionType . MEAN_SQUARED_ERROR : BinaryFunctionType . DIRECT_GRADIENT ) ; neuralNetwork . build ( ) ; neuralNetwork . setOptimizer ( OptimizationType . ADAM ) ; if ( ! policyGradient ) neuralNetwork . verboseTraining ( 100 ) ; neuralNetwork . setNeuralNetworkName ( "TicTacToe" ) ; return neuralNetwork ; }
Builds neural network for tic tac toe player (agent).
Builds neural network for tic tac toe player ( agent ) .