src/demo/Music.java
private static NeuralNetwork buildNeuralNetwork(int inputSize, int outputSize, int hiddenSize, int neuralNetworkType) throws DynamicParamException, NeuralNetworkException, MatrixException {
        NeuralNetwork neuralNetwork = new NeuralNetwork();
        neuralNetwork.addInputLayer("width = " + inputSize);
        neuralNetwork.addHiddenLayer(LayerType.BILSTM, "width = " + hiddenSize);
        switch (neuralNetworkType) {
            case 0 -> {
                neuralNetwork.addHiddenLayer(LayerType.FEEDFORWARD, new ActivationFunction(UnaryFunctionType.SOFTMAX), "width = " + outputSize);
                neuralNetwork.addOutputLayer(BinaryFunctionType.CROSS_ENTROPY);
            }
            case 1 -> {
                neuralNetwork.addHiddenLayer(LayerType.FEEDFORWARD, new ActivationFunction(UnaryFunctionType.SOFTMAX), "width = " + outputSize);
                neuralNetwork.addOutputLayer(BinaryFunctionType.CROSS_ENTROPY);
            }
            case 2 -> {
                neuralNetwork.addHiddenLayer(LayerType.FEEDFORWARD, new ActivationFunction(UnaryFunctionType.SOFTMAX), "width = " + outputSize);
                neuralNetwork.addOutputLayer(BinaryFunctionType.CROSS_ENTROPY);
            }
            default -> {
                System.out.println("Unknown loss type.");
                System.exit(-1);
            }
        }
        neuralNetwork.build();
        neuralNetwork.setOptimizer(OptimizationType.RADAM);
        return neuralNetwork;
    }
/**
     * Builds recurrent neural network (GRU) instance.
     *
     * @param inputSize input size of neural network (digits as one hot encoded in sequence).
     * @param outputSize output size of neural network (digits as one hot encoded in sequence).
     * @param hiddenSize hidden layer size of neural network.
     * @param neuralNetworkType neural network type (key, velocity or tick neural network).
     * @return neural network instance.
     * @throws DynamicParamException throws exception if setting of neural network parameters fail.
     * @throws NeuralNetworkException throws exception if creation of neural network instance fails.
     * @throws MatrixException throws exception if custom function is attempted to be created with this constructor.
     */
Builds recurrent neural network (GRU) instance.
@param inputSize input size of neural network (digits as one hot encoded in sequence).
@param outputSize output size of neural network (digits as one hot encoded in sequence).
@param hiddenSize hidden layer size of neural network.
@param neuralNetworkType neural network type (key, velocity or tick neural network).
@return neural network instance.
@throws DynamicParamException throws exception if setting of neural network parameters fail.
@throws NeuralNetworkException throws exception if creation of neural network instance fails.
@throws MatrixException throws exception if custom function is attempted to be created with this constructor.
Builds recurrent neural network ( GRU ) instance . @param inputSize input size of neural network ( digits as one hot encoded in sequence ) . @param outputSize output size of neural network ( digits as one hot encoded in sequence ) . @param hiddenSize hidden layer size of neural network . @param neuralNetworkType neural network type ( key velocity or tick neural network ) . @return neural network instance . @throws DynamicParamException throws exception if setting of neural network parameters fail . @throws NeuralNetworkException throws exception if creation of neural network instance fails . @throws MatrixException throws exception if custom function is attempted to be created with this constructor .
private static NeuralNetwork buildNeuralNetwork(int inputSize, int outputSize, int hiddenSize, int neuralNetworkType) throws DynamicParamException, NeuralNetworkException, MatrixException {
        NeuralNetwork neuralNetwork = new NeuralNetwork();
        neuralNetwork.addInputLayer("width = " + inputSize);
        neuralNetwork.addHiddenLayer(LayerType.BILSTM, "width = " + hiddenSize);
        switch (neuralNetworkType) {
            case 0 -> {
                neuralNetwork.addHiddenLayer(LayerType.FEEDFORWARD, new ActivationFunction(UnaryFunctionType.SOFTMAX), "width = " + outputSize);
                neuralNetwork.addOutputLayer(BinaryFunctionType.CROSS_ENTROPY);
            }
            case 1 -> {
                neuralNetwork.addHiddenLayer(LayerType.FEEDFORWARD, new ActivationFunction(UnaryFunctionType.SOFTMAX), "width = " + outputSize);
                neuralNetwork.addOutputLayer(BinaryFunctionType.CROSS_ENTROPY);
            }
            case 2 -> {
                neuralNetwork.addHiddenLayer(LayerType.FEEDFORWARD, new ActivationFunction(UnaryFunctionType.SOFTMAX), "width = " + outputSize);
                neuralNetwork.addOutputLayer(BinaryFunctionType.CROSS_ENTROPY);
            }
            default -> {
                System.out.println("Unknown loss type.");
                System.exit(-1);
            }
        }
        neuralNetwork.build();
        neuralNetwork.setOptimizer(OptimizationType.RADAM);
        return neuralNetwork;
    }
private static NeuralNetwork buildNeuralNetwork ( int inputSize , int outputSize , int hiddenSize , int neuralNetworkType ) throws DynamicParamException , NeuralNetworkException , MatrixException { NeuralNetwork neuralNetwork = new NeuralNetwork ( ) ; neuralNetwork . addInputLayer ( "width = " + inputSize ) ; neuralNetwork . addHiddenLayer ( LayerType . BILSTM , "width = " + hiddenSize ) ; switch ( neuralNetworkType ) { case 0 -> { neuralNetwork . addHiddenLayer ( LayerType . FEEDFORWARD , new ActivationFunction ( UnaryFunctionType . SOFTMAX ) , "width = " + outputSize ) ; neuralNetwork . addOutputLayer ( BinaryFunctionType . CROSS_ENTROPY ) ; } case 1 -> { neuralNetwork . addHiddenLayer ( LayerType . FEEDFORWARD , new ActivationFunction ( UnaryFunctionType . SOFTMAX ) , "width = " + outputSize ) ; neuralNetwork . addOutputLayer ( BinaryFunctionType . CROSS_ENTROPY ) ; } case 2 -> { neuralNetwork . addHiddenLayer ( LayerType . FEEDFORWARD , new ActivationFunction ( UnaryFunctionType . SOFTMAX ) , "width = " + outputSize ) ; neuralNetwork . addOutputLayer ( BinaryFunctionType . CROSS_ENTROPY ) ; } default -> { System . out . println ( "Unknown loss type." ) ; System . exit ( - 1 ) ; } } neuralNetwork . build ( ) ; neuralNetwork . setOptimizer ( OptimizationType . RADAM ) ; return neuralNetwork ; }
Builds recurrent neural network (GRU) instance.
Builds recurrent neural network ( GRU ) instance .