Giter Site home page Giter Site logo

dl-ali-doc's Introduction

How to Insert Analytical Library-computing Intelligent (ALI) to a Java Project in Intellij IDEA

These steps can be run after open the Java Project file

Open File menu and select Project Structure option

Jepretan Layar 2024-01-07 pukul 23 36 08

When Project Structure is open, select Modules in Project Settings section

Jepretan Layar 2024-01-07 pukul 23 42 31

Open Dependencies tab in Modules page, then click + button to select JARs or Directories option

Jepretan Layar 2024-01-07 pukul 23 43 08

Select ALI JAR file from local storage in the computer. After export process is success, there is new line on list of dependency like this

Jepretan Layar 2024-01-07 pukul 23 54 33

The functionalities can be called and used

Jepretan Layar 2024-01-08 pukul 00 08 16

How to Call The Functionalities

Read Image Dataset

Deep learning models are mathematical in nature and require numerical input. Each pixel in an image can be represented by its intensity values, and in the case of RGB (Red, Green, Blue) images, each pixel has three values corresponding to the intensity of red, green, and blue channels.

Jepretan Layar 2024-01-08 pukul 00 17 02

But, we must arrange the image dataset like this

Jepretan Layar 2024-01-08 pukul 00 25 04

For the ImageReader functionality, there are three main parameter that can be explored.

Parameter Options
mode "rgb" or "grayscale"
normalization true or false
alpha true or false

Input Layer

The input layer defines the shape and size of the input data that the neural network expects by specifying the number of features or dimensions in the input data. In this module, InputLayer doesn't need special parameters to set up.

Jepretan Layar 2024-01-08 pukul 09 09 55

Convolution Layer

Convolutional layer is a fundamental building block of Convolutional Neural Networks that designed to learn spatial hierarchies of features from the input data adaptively.

Jepretan Layar 2024-01-08 pukul 09 10 21

For the Convolution layer functionality, the are eight main parameter that can be explored.

Parameter Options
filter filter 2d in the form of 2x2, 3x3, 5x5
activation "relu", "leaky relu", "elu", "selu", "binary step", "tanh", "arc tan", "prelu", "soft plus", "soft sign", "linear"
strides [vertical, horizontal]
dilations [vertical, horizontal]
epoch 20, 40, 100, until infinity
erroType "mse" or "mae"
learningRate 0 until 1
weightInitial "xavier", "he", or "standard"

Filter

Filter is a small-sized matrix used for the convolution operation. During the training process, the network adjusts the values of the filter's weights to minimize the difference between the predicted output and the actual target.

Jepretan Layar 2024-01-08 pukul 08 46 36

Subsample

It is down-sampling operation to reduce the spatial dimensions of the input volume and subsequently decrease the computational complexity of the network.

Jepretan Layar 2024-01-08 pukul 09 11 13

For the Subsample layer functionality, there are four main parameter that can be explored.

Parameter Options
type "min", "max", or "average"
kernel [vertical, horizontal]
strides [vertical, horizontal]
dilations [vertical, horizontal]

Flatten

The purpose of the flatten operation is to transition from the spatial representation of features in the convolutional and pooling layers to a format that can be fed into traditional fully connected layers.

Jepretan Layar 2024-01-08 pukul 09 11 48

In this module, InputLayer functinality doesn't need special parameters to set up.

Fully Connected

Fully Connected is a type of layer where each neuron or node is connected to every neuron in the previous and the next layers. Unlike convolutional and pooling layers, which operate on local regions of the input, fully connected layers process the entire input.

Jepretan Layar 2024-01-08 pukul 09 42 44

For the Fully Connected layer functionality, the are six main parameter that can be explored.

Parameter Options
unit numerical array
activation "relu", "leaky relu", "elu", "selu", "binary step", "tanh", "arc tan", "prelu", "soft plus", "soft sign", "linear"
epoch 20, 40, 100, until infinity
erroType "mse" or "mae"
learningRate 0 until 1
weightInitial "xavier", "he", or "standard"

Sample Code

    String path = "/Users/oktaviacitra/cifar/";
    String[] labels = new LabelReader(path + "train/").getClasses();
    ImageReader reader = ImageReader.getInstance(labels, "grayscale").normalization(true);
    RandomState randomState = new RandomState();

    double[][][][] trainImages = reader.retrieve(path + "/train");
    double[][] trainTargets = reader.getTargets();
    trainImages = randomState.generate(trainImages, trainTargets);
    trainTargets = randomState.getTarget();

    double[][][][] testImages = reader.retrieve(path + "/test");
    double[][] testTargets = reader.getTargets();

    Input2DLayer inputLayer = Input2DLayer.getInstance("layer 2");
    double[][][][][] trainFeatures = inputLayer.transform(trainImages);
    double[][][][][] testFeatures = inputLayer.transform(testImages);

    double[][][] filter = new double[][][]{
            Filter2D.Kernel3x3.HORIZONTAL_LINES_DETECTION,
            Filter2D.Kernel2x2.ROBERTS_HORIZONTAL
    };

    Convolution2DLayer convolution2DLayer = Convolution2DLayer.getInstance("layer 2", filter)
            .activation("relu")
            .dilations(new int[]{1, 2})
            .strides(new int[]{2, 1})
            .epoch(20)
            .errorType("mae")
            .learningRate(0.01)
            .weightInitial("xavier");
    trainFeatures = convolution2DLayer.train(trainFeatures, testFeatures, true);
    testFeatures = convolution2DLayer.getTestOutputs();

    SubSample2DLayer subSample2DLayer = SubSample2DLayer.getInstance("layer 3", "max", new int[]{3, 3})
            .strides(new int[]{2, 2})
            .dilations(new int[]{2, 2});
    trainFeatures = subSample2DLayer.transform(trainFeatures);
    testFeatures = subSample2DLayer.transform(testFeatures);

    Flatten2DLayer flatten2DLayer = Flatten2DLayer.getInstance("layer 4");
    double[][] trainFlatten = flatten2DLayer.transform(trainFeatures);
    double[][] testFlatten = flatten2DLayer.transform(testFeatures);

    FullyConnectedLayer fullyConnectedLayer = FullyConnectedLayer
            .getInstance("layer 5", new int[]{32, 16, 10}, new String[]{"relu", "relu", "softmax"})
            .learningRate(0.01)
            .errorType("mae")
            .epoch(20)
            .weightInitial("he");
    double[][] trainOutputs = fullyConnectedLayer
            .train(trainFlatten, testFlatten, trainTargets, testTargets, true);
    double[][] testOutputs = fullyConnectedLayer.getTestOutputs();

dl-ali-doc's People

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.