{"id":46678,"date":"2021-12-08T00:00:00","date_gmt":"2021-12-08T08:00:00","guid":{"rendered":"https:\/\/griddb-linux-hte8hndjf8cka8ht.westus-01.azurewebsites.net\/blog\/how-to-implement-an-artificial-neural-network-using-java\/"},"modified":"2025-11-13T12:55:44","modified_gmt":"2025-11-13T20:55:44","slug":"how-to-implement-an-artificial-neural-network-using-java","status":"publish","type":"post","link":"https:\/\/griddb.net\/en\/blog\/how-to-implement-an-artificial-neural-network-using-java\/","title":{"rendered":"How to Implement an Artificial Neural Network Using Java"},"content":{"rendered":"<h2>What is an Artificial Neural Network?<\/h2>\n<p>Artificial neural networks (ANNs) are a subset of machine learning and they form the heart of deep learning algorithms. Their structure is inspired by the human brain, mimicking the way biological neurons send signals to each other.<\/p>\n<p>ANNs are made up of node layers, which contain an input layer, hidden layer(s), and an output layer. Each node is connected to another and is associated with a weight and a threshold. If an output of a particular node exceeds the specified threshold value, the node is activated, forwarding data to the next layer of the network. Otherwise, no data is forwarded to the next layer of the network.<\/p>\n<p><a href=\"https:\/\/griddb.net\/wp-content\/uploads\/2021\/12\/network.png\"><img fetchpriority=\"high\" decoding=\"async\" src=\"https:\/\/griddb.net\/wp-content\/uploads\/2021\/12\/network.png\" alt=\"\" width=\"360\" height=\"217\" class=\"aligncenter size-full wp-image-27924\" srcset=\"\/wp-content\/uploads\/2021\/12\/network.png 360w, \/wp-content\/uploads\/2021\/12\/network-300x181.png 300w\" sizes=\"(max-width: 360px) 100vw, 360px\" \/><\/a><\/p>\n<p>Neural network programmers use data to train and improve the accuracy of models over time. Once the learning algorithm is fine-tuned for accuracy, it becomes a powerful tool for prediction.<\/p>\n<h2>Write the Data into GridDB<\/h2>\n<p>In this article, we will help a bank to increase its customer retention rate. We will implement a neural network model that predicts the customers who are most likely to leave the bank. The dataset to be used shows the various details of bank customers, including their credit score, bank balance, whether they have a credit card, whether they are active, their estimated salary, and more.<\/p>\n<p><a href=\"https:\/\/griddb.net\/wp-content\/uploads\/2021\/12\/data-nural.png\"><img decoding=\"async\" src=\"https:\/\/griddb.net\/wp-content\/uploads\/2021\/12\/data-nural.png\" alt=\"\" width=\"1110\" height=\"198\" class=\"aligncenter size-full wp-image-27923\" srcset=\"\/wp-content\/uploads\/2021\/12\/data-nural.png 1110w, \/wp-content\/uploads\/2021\/12\/data-nural-300x54.png 300w, \/wp-content\/uploads\/2021\/12\/data-nural-1024x183.png 1024w, \/wp-content\/uploads\/2021\/12\/data-nural-768x137.png 768w, \/wp-content\/uploads\/2021\/12\/data-nural-600x107.png 600w\" sizes=\"(max-width: 1110px) 100vw, 1110px\" \/><\/a><\/p>\n<p>In total, there are 14 attributes in the dataset. We want to read the data from the CSV file and store it in GridDB. Let&#8217;s first import all the libraries to be used for this:<\/p>\n<div class=\"clipboard\">\n<pre><code class=\"language-java\">import java.io.IOException;\nimport java.util.Properties;\nimport java.util.Collection;\nimport java.util.Scanner;\n\nimport com.toshiba.mwcloud.gs.Collection;\nimport com.toshiba.mwcloud.gs.GridStore;\nimport com.toshiba.mwcloud.gs.GSException;\nimport com.toshiba.mwcloud.gs.GridStoreFactory;\nimport com.toshiba.mwcloud.gs.RowKey;\nimport com.toshiba.mwcloud.gs.Query;\nimport com.toshiba.mwcloud.gs.RowSet;\n\nimport java.io.File;<\/code><\/pre>\n<\/div>\n<p>The data has been stored in a CSV file named <code>Churn_Modelling.csv<\/code>. We will store this data in a GridDB container, so let us create a static class to represent the container schema:<\/p>\n<div class=\"clipboard\">\n<pre><code class=\"language-java\">public static class BankCustomers {\n    \n     @RowKey String rowNumber;\n     String  surname, geography, gender, tenure, hasCrCard, isActiveMember; \n     int customerId,  creditScore, age, numOfProducts, exited;\n     Double balance, estimatedSalary;\n}  <\/code><\/pre>\n<\/div>\n<p>The above class is similar to a SQL table, with the variables representing the table columns.<\/p>\n<p>It&#8217;s now time to establish a connection to GridDB. Let&#8217;s create a Properties instance with the details of our GridDB installation:<\/p>\n<div class=\"clipboard\">\n<pre><code class=\"language-java\">        Properties props = new Properties();\n        props.setProperty(\"notificationAddress\", \"239.0.0.1\");\n        props.setProperty(\"notificationPort\", \"31999\");\n        props.setProperty(\"clusterName\", \"defaultCluster\");\n        props.setProperty(\"user\", \"admin\");\n        props.setProperty(\"password\", \"admin\");\n        GridStore store = GridStoreFactory.getInstance().getGridStore(props);<\/code><\/pre>\n<\/div>\n<p>Change the above details to match the specifics of your GridDB installation.<\/p>\n<p>Next, let&#8217;s select the <code>BankCustomers<\/code> container:<\/p>\n<div class=\"clipboard\">\n<pre><code class=\"language-java\">Collection&lt;String, BankCustomers> coll = store.putCollection(\"col01\", BankCustomers.class);<\/code><\/pre>\n<\/div>\n<p>An instance for the container has been created and given the name <code>coll<\/code>. We will be using it any time we need to refer to the container.<\/p>\n<p>It&#8217;s now time to read the data from the CSV file and store it in a GridDB container. We can use the following code:<\/p>\n<div class=\"clipboard\">\n<pre><code class=\"language-java\">File file1 = new File(\"Churn_Modelling.csv\");\n                Scanner sc = new Scanner(file1);\n                String data = sc.next();\n                \n                 \n                while (sc.hasNext()){\n                        String scData = sc.next();\n                        String dataList[] = scData.split(\",\");\n                        \n                       \n                        String rowNumber = dataList[0];\n                        String customerId = dataList[1];\n                        String surname = dataList[2];\n                        String creditScore = dataList[3];\n                        String geography = dataList[4];\n                        String gender = dataList[5];\n                        String age = dataList[6];\n                        String tenure = dataList[7];\n                        String balance = dataList[8];\n                        String numOfProducts = dataList[9];\n                        String hasCrCard = dataList[10];\n                        String isActiveMember = dataList[11];\n                        String estimatedSalary = dataList[12];\n                        String exited = dataList[13];\n                        \n                        \n                        \n                        BankCustomers bc = new BankCustomers();\n                        \n                        \n                        bc.rowNumber = rowNumber; \n                        bc.customerId = Integer.parseInt(customerId);\n                        bc.surname = surname;\n                        bc.creditScore = Integer.parseInt(creditScore);\n                        bc.geography = geography;\n                        bc.gender = gender;\n                        bc.age = Integer.parseInt(age);\n                        bc.tenure = tenure;\n                        bc.balance = Double.parseDouble(balance);\n                        bc.numOfProducts = Integer.parseInt(numOfProducts);\n                        bc.hasCrCard = hasCrCard;\n                        bc.isActiveMember = isActiveMember;\n                        bc.estimatedSalary = Double.parseDouble(estimatedSalary);\n                        bc.exited =Integer.parseInt(exited);\n                        coll.append(bc);                                           \n                }<\/code><\/pre>\n<\/div>\n<p>The code read data from the CSV file and created an object named <code>bc<\/code>. The object has then been appended to the container.<\/p>\n<h2>Retrieve the Data from GridDB<\/h2>\n<p>We can now pull the data from GridDB. The following code demonstrates how to do this:<\/p>\n<div class=\"clipboard\">\n<pre><code class=\"language-java\">Query&lt;bankcustomers> query = coll.query(\"select *\");\n                RowSet&lt;\/bankcustomers>&lt;bankcustomers> rs = query.fetch(false);\n            RowSet res = query.fetch();&lt;\/bankcustomers><\/code><\/pre>\n<\/div>\n<p>The <code>select *<\/code> statements helps us to select all data stored in the GridDB container.<\/p>\n<h2>Data Pre-Processing<\/h2>\n<p>Since there are categorical variables in the dataset, we will transform them before feeding them to the neural network. The last field of the dataset, that is, Exited, shows whether the customer left the bank or not. A value of 1 indicates that the customer has left the bank, thus, this attribute will be our output label.<\/p>\n<p>The first three attributes, that is, RowNumber, CustomerId, and Surname can be ignored as they are not deciding factors. This leaves us with 10 attributes for consideration and the output label.<\/p>\n<p>The values for <code>Geography<\/code> and <code>Gender<\/code> are not numerical, so we should convert them into digits. The <code>Gender<\/code> label will be mapped to binary values, that is, 0 or 1 (male\/female). Since there are multiple values for <code>Geography<\/code>, we will use one hot encoding to encode them into digit values.<\/p>\n<p>We will use the DeepLearning4j (DL4J) library to define a schema for this dataset and then feed the schema into a transform process. The data can then be taken through encoding and transformation.<\/p>\n<p>First, let&#8217;s import a set of additional libraries to be used:<\/p>\n<div class=\"clipboard\">\n<pre><code class=\"language-java\">import org.datavec.api.records.reader.RecordReader;\nimport org.datavec.api.records.reader.impl.transform.TransformProcessRecordReader;\nimport org.datavec.api.records.reader.impl.csv.CSVRecordReader;\nimport org.datavec.api.split.FileSplit;\nimport org.datavec.api.transform.TransformProcess;\nimport org.deeplearning4j.api.storage.StatsStorage;\nimport org.datavec.api.transform.schema.Schema;\nimport org.deeplearning4j.datasets.datavec.RecordReaderDataSetIterator;\nimport org.deeplearning4j.datasets.iterator.DataSetIteratorSplitter;\nimport org.deeplearning4j.nn.conf.NeuralNetConfiguration;\nimport org.deeplearning4j.nn.conf.MultiLayerConfiguration;\nimport org.deeplearning4j.nn.conf.layers.DenseLayer;\nimport org.deeplearning4j.nn.conf.layers.OutputLayer;\nimport org.deeplearning4j.nn.weights.WeightInit;\nimport org.deeplearning4j.nn.multilayer.MultiLayerNetwork;\nimport org.deeplearning4j.optimize.listeners.ScoreIterationListener;\nimport org.deeplearning4j.ui.api.UIServer;\nimport org.deeplearning4j.ui.storage.InMemoryStatsStorage;\nimport org.deeplearning4j.ui.stats.StatsListener;\nimport org.deeplearning4j.util.ModelSerializer;\nimport org.nd4j.evaluation.classification.Evaluation;\nimport org.nd4j.linalg.api.ndarray.INDArray;\nimport org.nd4j.linalg.activations.Activation;\nimport org.nd4j.linalg.dataset.api.iterator.DataSetIterator;\nimport org.nd4j.linalg.dataset.api.preprocessor.NormalizerStandardize;\nimport org.nd4j.linalg.dataset.api.preprocessor.DataNormalization;\nimport org.nd4j.linalg.factory.Nd4j;\nimport org.nd4j.linalg.learning.config.Adam;\nimport org.nd4j.linalg.io.ClassPathResource;\nimport org.nd4j.linalg.lossfunctions.impl.LossMCXENT;\nimport org.slf4j.LoggerFactory;\nimport org.slf4j.Logger;\n\nimport java.util.Arrays;\n<\/code><\/pre>\n<\/div>\n<p>You can then use the following code to implement the schema:<\/p>\n<div class=\"clipboard\">\n<pre><code class=\"language-java\"> private static Schema createSchema() {\n        final Schema scm = new Schema.Builder()\n                                    .addColumnString(\"rowNumber\")\n                                    .addColumnInteger(\"customerId\")\n                                    .addColumnString(\"surname\")\n                                    .addColumnInteger(\"creditScore\")\n                                    .addColumnCategorical(\"geography\", Arrays.asList(\"France\",\"Germany\",\"Spain\"))\n                                    .addColumnCategorical(\"gender\", Arrays.asList(\"Male\",\"Female\"))\n                                    .addColumnsInteger(\"age\", \"tenure\")\n                                    .addColumnDouble(\"balance\")\n                                    .addColumnsInteger(\"numOfProducts\",\"hasCrCard\",\"isActiveMember\")\n                                    .addColumnDouble(\"estimatedSalary\")\n                                    .addColumnInteger(\"exited\")\n                                    .build();\n        return scm;\n\n    }<\/code><\/pre>\n<\/div>\n<p>Now that we have created a schema for the data, we can pass it through a transform process. The following code demonstrates this:<\/p>\n<div class=\"clipboard\">\n<pre><code class=\"language-java\"> private static RecordReader dataTransform(RecordReader reader, Schema scm){\n    final TransformProcess transformation = new TransformProcess.Builder(scm)\n                        \n        .removeColumns(\"rowNumber\",\"customerId\",\"surname\")\n        .categoricalToInteger(\"gender\")\n        .categoricalToOneHot(\"geography\")\n        .removeColumns(\"geography[France]\")\n        .build();\n        \n        final TransformProcessRecordReader transformationReader = new TransformProcessRecordReader(reader,transformation);\n        return  transformationReader;\n\n    }<\/code><\/pre>\n<\/div>\n<p>The encoding will transform the <code>geography<\/code> label into multiple columns with binary values. For example, if we have 3 countries in the dataset, they will be mapped into 3 columns with each column representing a country value.<\/p>\n<p>We have also removed one categorical variable to avoid the dummy variable trap. The removed variable should become the base category against the other categories. We removed <code>France<\/code>, so it will act as the base for indicating the other country values.<\/p>\n<h2>Split the Data into Train and Test Sets<\/h2>\n<p>The training dataset will be used to train the neural network model while the test dataset will help us to validate how well the model has been trained. Here is the code for splitting the data:<\/p>\n<div class=\"clipboard\">\n<pre><code class=\"language-java\">private static RecordReader generateReader(File file) throws IOException, InterruptedException {\n    final RecordReader reader = new RecordReader();\n    reader.initialize(new FileSplit(res));\n\n\n      reader.initialize(res);\n        final RecordReader transformationReader=applyTransform(reader,createSchema());\n        return transformationReader;\n    }<\/code><\/pre>\n<\/div>\n<h2>Define the Input and Output Labels<\/h2>\n<p>It&#8217;s now time to define the input and output labels. After applying transformations, the resulting data should have 13 columns. This means the indexes should run from 0 to 12. The last columns shows the output labels and the other columns are the input labels.<\/p>\n<p>It&#8217;s also good to define the batch size for the dataset. The batch size will define the quantity by which data will be transferred from the dataset to the neural network. We will create a DataSetIterator for that as shown below:<\/p>\n<div class=\"clipboard\">\n<pre><code class=\"language-java\">final int labIndex=11;\n    final int numClasses=2;\n    final int batchSize=8;\n    final INDArray weightArray = Nd4j.create(new double[]{0.57, 0.75});\n\n    final RecordReader reader = generateReader(res);\n    final DataSetIterator iterator = new RecordReaderDataSetIterator.Builder(reader,batchSize)\n        .classification(labIndex,numClasses)\n        .build();<\/code><\/pre>\n<\/div>\n<h2>Data Scaling<\/h2>\n<p>The labels of the data you feed to a neural network should be comparable to each other. In our case, the magnitude of the <code>balance<\/code> and <code>estimated salary<\/code> labels is too high than the other labels. If we use the data as it is, these two labels will hide the impact of the other labels in making predictions.<\/p>\n<p>To solve this problem, we will use feature scaling as shown in the following code:<\/p>\n<div class=\"clipboard\">\n<pre><code class=\"language-java\">final DataNormalization normalization = new NormalizerStandardize();\n       normalization.fit(iterator);\n       iterator.setPreProcessor(normalization);\n       final DataSetIteratorSplitter iteratorSplitter = new DataSetIteratorSplitter(iterator,1250,0.8);<\/code><\/pre>\n<\/div>\n<p>At this point, the data is ready to be fed into a neural network.<\/p>\n<h2>Define the Neural Network<\/h2>\n<p>It&#8217;s now time to define the neural network configuration. This involves defining the number of neurons to be added to the input layer, the structure and connections for the hidden layer, output layer, the activation function to be used in each layer, the optimizer function, and the loss function for the output layer.<\/p>\n<p>The following code demonstrates this:<\/p>\n<div class=\"clipboard\">\n<pre><code class=\"language-java\">final MultiLayerConfiguration config = new NeuralNetConfiguration.Builder()\n    \n    .weightInit(WeightInit.RELU_UNIFORM)\n    \n    .updater(new Adam(0.015D))\n    \n    .list()\n    \n    .layer(new DenseLayer.Builder().nIn(11).nOut(6).activation(Activation.RELU).dropOut(0.9).build())\n    \n    .layer(new DenseLayer.Builder().nIn(6).nOut(6).activation(Activation.RELU).dropOut(0.9).build())\n    \n    .layer(new DenseLayer.Builder().nIn(6).nOut(4).activation(Activation.RELU).dropOut(0.9).build())\n    \n    .layer(new OutputLayer.Builder(new LossMCXENT(weightArray)).nIn(4).nOut(2).activation(Activation.SOFTMAX).build())\n    \n    .build();<\/code><\/pre>\n<\/div>\n<p>Note that we have added dropouts in between the input and the output layers to help us avoid over-fitting. Also, only 10% of the neurons was dropped to avoid under-fitting. We also set the number of inputs to 11 and the number of outputs to 1.<\/p>\n<p>We have also used the <code>sigmoid<\/code> activation function in the output layer of the network. We also specified the loss function together with the error rate to be calculated. In this case, we are calculating the sum of squares of the difference between the actual output and the expected output. The corresponding loss function is the <em>binary cross-enthropy<\/em>.<\/p>\n<h2>Train the Model<\/h2>\n<p>Let&#8217;s first compile and then initialize the model:<\/p>\n<div class=\"clipboard\">\n<pre><code class=\"language-java\">  final UIServer ui = UIServer.getInstance();\n        final StatsStorage stats = new InMemoryStatsStorage();\n\n        final MultiLayerNetwork multiNetwork = new MultiLayerNetwork(config);\n        multiNetwork.init();\n        multiNetwork.setListeners(new ScoreIterationListener(100),\n                                       new StatsListener(stats));\n        ui.attach(stats);<\/code><\/pre>\n<\/div>\n<p>Let&#8217;s call the <code>fit()<\/code> method to train the neural network model:<\/p>\n<div class=\"clipboard\">\n<pre><code class=\"language-java\">    multiNetwork.fit(iteratorSplitter.getTrainIterator(),100);<\/code><\/pre>\n<\/div>\n<p>Let us use the <code>Evaluation<\/code> class provided by DL4J to evaluate the model results:<\/p>\n<div class=\"clipboard\">\n<pre><code class=\"language-java\">final Evaluation ev =  multiNetwork.evaluate(iteratorSplitter.getTestIterator(),Arrays.asList(\"0\",\"1\"));\n        System.out.println(ev.stats());<\/code><\/pre>\n<\/div>\n<p>The results will be shown in the form of a confusion matrix.<\/p>\n<h2>Make Predictions<\/h2>\n<p>We want to see the neural network model in action. We will make a prediction to tell us whether a particular customer will leave the bank.<\/p>\n<p>The test dataset will not have an output label, thus, we should create a new schema for it. You only have to remove the label from the previously defined schema. Your new schema should be as shown below:<\/p>\n<div class=\"clipboard\">\n<pre><code class=\"language-java\"> private static Schema createSchema() {\n        final Schema scm = new Schema.Builder()\n           .addColumnString(\"rowNumber\")\n           .addColumnInteger(\"customerId\")\n           .addColumnString(\"surname\")\n           .addColumnInteger(\"creditScore\")\n           .addColumnCategorical(\"geography\", Arrays.asList(\"France\",\"Germany\",\"Spain\"))\n           .addColumnCategorical(\"gender\", Arrays.asList(\"Male\",\"Female\"))\n           .addColumnsInteger(\"age\", \"tenure\")\n           .addColumnDouble(\"balance\")\n           \n           .addColumnsInteger(\"numOfProducts\",\"hasCrCard\",\"isActiveMember\")\n           .addColumnDouble(\"estimatedSalary\")\n           .build();\n        return scm;\n\n    }<\/code><\/pre>\n<\/div>\n<p>We can now create an API function that will return the prediction results as INDArray:<\/p>\n<div class=\"clipboard\">\n<pre><code class=\"language-java\">public static INDArray predictedOutput(File inputFile, String modelPath) throws IOException, InterruptedException {\n        final File file = new File(modelPath);\n        final MultiLayerNetwork net = ModelSerializer.restoreMultiLayerNetwork(file);\n        final RecordReader reader = generateReader(inputFile);\n        final NormalizerStandardize normalizerStandardize = ModelSerializer.restoreNormalizerFromFile(file);\n        final DataSetIterator iterator = new RecordReaderDataSetIterator.Builder(reader,1).build();\n        normalizerStandardize.fit(iterator);\n        iterator.setPreProcessor(normalizerStandardize);\n        return net.output(iterator);\n\n    }<\/code><\/pre>\n<\/div>\n<p>Next, we will be compiling and executing the code.<\/p>\n<h2>Compile and Run the Code<\/h2>\n<p>First, login as the <code>gsadm<\/code> user. Move your <code>.java<\/code> file to the <code>bin<\/code> folder of your GridDB located in the following path:<\/p>\n<p>\/griddb_4.6.0-1_amd64\/usr\/griddb-4.6.0\/bin<\/p>\n<p>Next, run the following command on your Linux terminal to set the path for the gridstore.jar file:<\/p>\n<div class=\"clipboard\">\n<pre><code class=\"language-sh\">export CLASSPATH=$CLASSPATH:\/home\/osboxes\/Downloads\/griddb_4.6.0-1_amd64\/usr\/griddb-4.6.0\/bin\/gridstore.jar<\/code><\/pre>\n<\/div>\n<p>Next, run the following command to compile your <code>.java<\/code> file:<\/p>\n<div class=\"clipboard\">\n<pre><code class=\"language-sh\">javac BankRetention.java<\/code><\/pre>\n<\/div>\n<p>Run the .class file that is generated by running the following command:<\/p>\n<div class=\"clipboard\">\n<pre><code class=\"language-sh\">java BankRetention<\/code><\/pre>\n<\/div>\n<p>The neural network will predict the probability that the customer leaves the bank. If the probability is above 0.5 (50%), it is an indication of an unhappy customer.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>What is an Artificial Neural Network? Artificial neural networks (ANNs) are a subset of machine learning and they form the heart of deep learning algorithms. Their structure is inspired by the human brain, mimicking the way biological neurons send signals to each other. ANNs are made up of node layers, which contain an input layer, [&hellip;]<\/p>\n","protected":false},"author":41,"featured_media":27960,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[121],"tags":[],"class_list":["post-46678","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-blog"],"acf":[],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.1.1 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>How to Implement an Artificial Neural Network Using Java | GridDB: Open Source Time Series Database for IoT<\/title>\n<meta name=\"description\" content=\"What is an Artificial Neural Network? Artificial neural networks (ANNs) are a subset of machine learning and they form the heart of deep learning\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/griddb.net\/en\/blog\/how-to-implement-an-artificial-neural-network-using-java\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"How to Implement an Artificial Neural Network Using Java | GridDB: Open Source Time Series Database for IoT\" \/>\n<meta property=\"og:description\" content=\"What is an Artificial Neural Network? Artificial neural networks (ANNs) are a subset of machine learning and they form the heart of deep learning\" \/>\n<meta property=\"og:url\" content=\"https:\/\/griddb.net\/en\/blog\/how-to-implement-an-artificial-neural-network-using-java\/\" \/>\n<meta property=\"og:site_name\" content=\"GridDB: Open Source Time Series Database for IoT\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/griddbcommunity\/\" \/>\n<meta property=\"article:published_time\" content=\"2021-12-08T08:00:00+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2025-11-13T20:55:44+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/griddb.net\/wp-content\/uploads\/2021\/12\/neural.png\" \/>\n\t<meta property=\"og:image:width\" content=\"1160\" \/>\n\t<meta property=\"og:image:height\" content=\"653\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/png\" \/>\n<meta name=\"author\" content=\"griddb-admin\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@GridDBCommunity\" \/>\n<meta name=\"twitter:site\" content=\"@GridDBCommunity\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"griddb-admin\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"11 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/griddb.net\/en\/blog\/how-to-implement-an-artificial-neural-network-using-java\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/griddb.net\/en\/blog\/how-to-implement-an-artificial-neural-network-using-java\/\"},\"author\":{\"name\":\"griddb-admin\",\"@id\":\"https:\/\/griddb.net\/en\/#\/schema\/person\/4fe914ca9576878e82f5e8dd3ba52233\"},\"headline\":\"How to Implement an Artificial Neural Network Using Java\",\"datePublished\":\"2021-12-08T08:00:00+00:00\",\"dateModified\":\"2025-11-13T20:55:44+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/griddb.net\/en\/blog\/how-to-implement-an-artificial-neural-network-using-java\/\"},\"wordCount\":1360,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\/\/griddb.net\/en\/#organization\"},\"image\":{\"@id\":\"https:\/\/griddb.net\/en\/blog\/how-to-implement-an-artificial-neural-network-using-java\/#primaryimage\"},\"thumbnailUrl\":\"\/wp-content\/uploads\/2021\/12\/neural.png\",\"articleSection\":[\"Blog\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/griddb.net\/en\/blog\/how-to-implement-an-artificial-neural-network-using-java\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/griddb.net\/en\/blog\/how-to-implement-an-artificial-neural-network-using-java\/\",\"url\":\"https:\/\/griddb.net\/en\/blog\/how-to-implement-an-artificial-neural-network-using-java\/\",\"name\":\"How to Implement an Artificial Neural Network Using Java | GridDB: Open Source Time Series Database for IoT\",\"isPartOf\":{\"@id\":\"https:\/\/griddb.net\/en\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/griddb.net\/en\/blog\/how-to-implement-an-artificial-neural-network-using-java\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/griddb.net\/en\/blog\/how-to-implement-an-artificial-neural-network-using-java\/#primaryimage\"},\"thumbnailUrl\":\"\/wp-content\/uploads\/2021\/12\/neural.png\",\"datePublished\":\"2021-12-08T08:00:00+00:00\",\"dateModified\":\"2025-11-13T20:55:44+00:00\",\"description\":\"What is an Artificial Neural Network? Artificial neural networks (ANNs) are a subset of machine learning and they form the heart of deep learning\",\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/griddb.net\/en\/blog\/how-to-implement-an-artificial-neural-network-using-java\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/griddb.net\/en\/blog\/how-to-implement-an-artificial-neural-network-using-java\/#primaryimage\",\"url\":\"\/wp-content\/uploads\/2021\/12\/neural.png\",\"contentUrl\":\"\/wp-content\/uploads\/2021\/12\/neural.png\",\"width\":1160,\"height\":653},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/griddb.net\/en\/#website\",\"url\":\"https:\/\/griddb.net\/en\/\",\"name\":\"GridDB: Open Source Time Series Database for IoT\",\"description\":\"GridDB is an open source time-series database with the performance of NoSQL and convenience of SQL\",\"publisher\":{\"@id\":\"https:\/\/griddb.net\/en\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/griddb.net\/en\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\/\/griddb.net\/en\/#organization\",\"name\":\"Fixstars\",\"url\":\"https:\/\/griddb.net\/en\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/griddb.net\/en\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/griddb.net\/wp-content\/uploads\/2019\/04\/fixstars_logo_web_tagline.png\",\"contentUrl\":\"https:\/\/griddb.net\/wp-content\/uploads\/2019\/04\/fixstars_logo_web_tagline.png\",\"width\":200,\"height\":83,\"caption\":\"Fixstars\"},\"image\":{\"@id\":\"https:\/\/griddb.net\/en\/#\/schema\/logo\/image\/\"},\"sameAs\":[\"https:\/\/www.facebook.com\/griddbcommunity\/\",\"https:\/\/x.com\/GridDBCommunity\",\"https:\/\/www.linkedin.com\/company\/griddb-by-toshiba\"]},{\"@type\":\"Person\",\"@id\":\"https:\/\/griddb.net\/en\/#\/schema\/person\/4fe914ca9576878e82f5e8dd3ba52233\",\"name\":\"griddb-admin\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/griddb.net\/en\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/5bceca1cafc06886a7ba873e2f0a28011a1176c4dea59709f735b63ae30d0342?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/5bceca1cafc06886a7ba873e2f0a28011a1176c4dea59709f735b63ae30d0342?s=96&d=mm&r=g\",\"caption\":\"griddb-admin\"},\"url\":\"https:\/\/griddb.net\/en\/author\/griddb-admin\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"How to Implement an Artificial Neural Network Using Java | GridDB: Open Source Time Series Database for IoT","description":"What is an Artificial Neural Network? Artificial neural networks (ANNs) are a subset of machine learning and they form the heart of deep learning","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/griddb.net\/en\/blog\/how-to-implement-an-artificial-neural-network-using-java\/","og_locale":"en_US","og_type":"article","og_title":"How to Implement an Artificial Neural Network Using Java | GridDB: Open Source Time Series Database for IoT","og_description":"What is an Artificial Neural Network? Artificial neural networks (ANNs) are a subset of machine learning and they form the heart of deep learning","og_url":"https:\/\/griddb.net\/en\/blog\/how-to-implement-an-artificial-neural-network-using-java\/","og_site_name":"GridDB: Open Source Time Series Database for IoT","article_publisher":"https:\/\/www.facebook.com\/griddbcommunity\/","article_published_time":"2021-12-08T08:00:00+00:00","article_modified_time":"2025-11-13T20:55:44+00:00","og_image":[{"width":1160,"height":653,"url":"https:\/\/griddb.net\/wp-content\/uploads\/2021\/12\/neural.png","type":"image\/png"}],"author":"griddb-admin","twitter_card":"summary_large_image","twitter_creator":"@GridDBCommunity","twitter_site":"@GridDBCommunity","twitter_misc":{"Written by":"griddb-admin","Est. reading time":"11 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/griddb.net\/en\/blog\/how-to-implement-an-artificial-neural-network-using-java\/#article","isPartOf":{"@id":"https:\/\/griddb.net\/en\/blog\/how-to-implement-an-artificial-neural-network-using-java\/"},"author":{"name":"griddb-admin","@id":"https:\/\/griddb.net\/en\/#\/schema\/person\/4fe914ca9576878e82f5e8dd3ba52233"},"headline":"How to Implement an Artificial Neural Network Using Java","datePublished":"2021-12-08T08:00:00+00:00","dateModified":"2025-11-13T20:55:44+00:00","mainEntityOfPage":{"@id":"https:\/\/griddb.net\/en\/blog\/how-to-implement-an-artificial-neural-network-using-java\/"},"wordCount":1360,"commentCount":0,"publisher":{"@id":"https:\/\/griddb.net\/en\/#organization"},"image":{"@id":"https:\/\/griddb.net\/en\/blog\/how-to-implement-an-artificial-neural-network-using-java\/#primaryimage"},"thumbnailUrl":"\/wp-content\/uploads\/2021\/12\/neural.png","articleSection":["Blog"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/griddb.net\/en\/blog\/how-to-implement-an-artificial-neural-network-using-java\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/griddb.net\/en\/blog\/how-to-implement-an-artificial-neural-network-using-java\/","url":"https:\/\/griddb.net\/en\/blog\/how-to-implement-an-artificial-neural-network-using-java\/","name":"How to Implement an Artificial Neural Network Using Java | GridDB: Open Source Time Series Database for IoT","isPartOf":{"@id":"https:\/\/griddb.net\/en\/#website"},"primaryImageOfPage":{"@id":"https:\/\/griddb.net\/en\/blog\/how-to-implement-an-artificial-neural-network-using-java\/#primaryimage"},"image":{"@id":"https:\/\/griddb.net\/en\/blog\/how-to-implement-an-artificial-neural-network-using-java\/#primaryimage"},"thumbnailUrl":"\/wp-content\/uploads\/2021\/12\/neural.png","datePublished":"2021-12-08T08:00:00+00:00","dateModified":"2025-11-13T20:55:44+00:00","description":"What is an Artificial Neural Network? Artificial neural networks (ANNs) are a subset of machine learning and they form the heart of deep learning","inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/griddb.net\/en\/blog\/how-to-implement-an-artificial-neural-network-using-java\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/griddb.net\/en\/blog\/how-to-implement-an-artificial-neural-network-using-java\/#primaryimage","url":"\/wp-content\/uploads\/2021\/12\/neural.png","contentUrl":"\/wp-content\/uploads\/2021\/12\/neural.png","width":1160,"height":653},{"@type":"WebSite","@id":"https:\/\/griddb.net\/en\/#website","url":"https:\/\/griddb.net\/en\/","name":"GridDB: Open Source Time Series Database for IoT","description":"GridDB is an open source time-series database with the performance of NoSQL and convenience of SQL","publisher":{"@id":"https:\/\/griddb.net\/en\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/griddb.net\/en\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/griddb.net\/en\/#organization","name":"Fixstars","url":"https:\/\/griddb.net\/en\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/griddb.net\/en\/#\/schema\/logo\/image\/","url":"https:\/\/griddb.net\/wp-content\/uploads\/2019\/04\/fixstars_logo_web_tagline.png","contentUrl":"https:\/\/griddb.net\/wp-content\/uploads\/2019\/04\/fixstars_logo_web_tagline.png","width":200,"height":83,"caption":"Fixstars"},"image":{"@id":"https:\/\/griddb.net\/en\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/griddbcommunity\/","https:\/\/x.com\/GridDBCommunity","https:\/\/www.linkedin.com\/company\/griddb-by-toshiba"]},{"@type":"Person","@id":"https:\/\/griddb.net\/en\/#\/schema\/person\/4fe914ca9576878e82f5e8dd3ba52233","name":"griddb-admin","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/griddb.net\/en\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/5bceca1cafc06886a7ba873e2f0a28011a1176c4dea59709f735b63ae30d0342?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/5bceca1cafc06886a7ba873e2f0a28011a1176c4dea59709f735b63ae30d0342?s=96&d=mm&r=g","caption":"griddb-admin"},"url":"https:\/\/griddb.net\/en\/author\/griddb-admin\/"}]}},"_links":{"self":[{"href":"https:\/\/griddb.net\/en\/wp-json\/wp\/v2\/posts\/46678","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/griddb.net\/en\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/griddb.net\/en\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/griddb.net\/en\/wp-json\/wp\/v2\/users\/41"}],"replies":[{"embeddable":true,"href":"https:\/\/griddb.net\/en\/wp-json\/wp\/v2\/comments?post=46678"}],"version-history":[{"count":1,"href":"https:\/\/griddb.net\/en\/wp-json\/wp\/v2\/posts\/46678\/revisions"}],"predecessor-version":[{"id":51352,"href":"https:\/\/griddb.net\/en\/wp-json\/wp\/v2\/posts\/46678\/revisions\/51352"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/griddb.net\/en\/wp-json\/wp\/v2\/media\/27960"}],"wp:attachment":[{"href":"https:\/\/griddb.net\/en\/wp-json\/wp\/v2\/media?parent=46678"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/griddb.net\/en\/wp-json\/wp\/v2\/categories?post=46678"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/griddb.net\/en\/wp-json\/wp\/v2\/tags?post=46678"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}