<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Abhisar Shukla</title>
    <description>The latest articles on DEV Community by Abhisar Shukla (@abhisarshukla).</description>
    <link>https://dev.to/abhisarshukla</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F177854%2F6a74e8d3-07be-404e-9c9a-1c689e4d8d23.png</url>
      <title>DEV Community: Abhisar Shukla</title>
      <link>https://dev.to/abhisarshukla</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/abhisarshukla"/>
    <language>en</language>
    <item>
      <title>A Very General Introduction to Keras</title>
      <dc:creator>Abhisar Shukla</dc:creator>
      <pubDate>Mon, 17 Jun 2019 09:54:56 +0000</pubDate>
      <link>https://dev.to/abhisarshukla/a-very-general-introduction-to-keras-1g33</link>
      <guid>https://dev.to/abhisarshukla/a-very-general-introduction-to-keras-1g33</guid>
      <description>&lt;p&gt;In this era of deeplearning, it is being applied to every single place to make life of humans easier than before. They are used in our phone cameras, search engines, cancer treatment, nuclear research, quantum physics research and many more places where it just goes without noticing. All the applications using deeplearning use a trained model to make predictions on the previously unseen examples. Models making predictions are first created and trained on a huge training dataset and evaluated on a test dataset which is smaller in size than the training set. An evaluation dataset is also used to adjust the hyper-parameters of the model.&lt;/p&gt;




&lt;p&gt;Deeplearning models can be created and trained using many frameworks that are available free and open-source such as:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://www.tensorflow.org"&gt;Tensorflow&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://pytorch.org"&gt;Pytorch&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://caffe2.ai"&gt;Caffe2&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://docs.microsoft.com/en-us/cognitive-toolkit"&gt;CNTK&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Each of the above frameworks have an API for python, which is &lt;strong&gt;great!&lt;/strong&gt; But and it is a big BUT that programming directly in these frameworks is somewhat not beginner friendly as it requires you to have a deep understanding of the deeplearning methods, such as:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Initialization of the parameters.&lt;/li&gt;
&lt;li&gt;Size of the weight tensors.&lt;/li&gt;
&lt;li&gt;Figuring out tensor multiplication.&lt;/li&gt;
&lt;li&gt;Lots of API docs&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;and so on.&lt;br&gt;
Now these things are not easy to figure out and it can easily drag you out of the idea of writing a program yourself. This is where Keras comes into picture.&lt;/p&gt;


&lt;h2&gt;
  
  
  &lt;a href="https://keras.io"&gt;Keras&lt;/a&gt;
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--V9kO3IHA--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://s3.amazonaws.com/keras.io/img/keras-logo-2018-large-1200.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--V9kO3IHA--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://s3.amazonaws.com/keras.io/img/keras-logo-2018-large-1200.png" alt="Keras logo"&gt;&lt;/a&gt;Keras Logo&lt;/p&gt;

&lt;p&gt;Keras is programming framework that is built to run upon other deeplearning frameworks such as the ones' mentioned above. In their own words:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Keras is a high-level neural networks API, written in Python and capable of running on top of TensorFlow, CNTK, or Theano. It was developed with a focus on enabling fast experimentation. Being able to go from idea to result with the least possible delay is key to doing good research.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Now let's just jump into it!&lt;/p&gt;
&lt;h2&gt;
  
  
  Installation
&lt;/h2&gt;

&lt;p&gt;For installation I would recommend setting up a virtual environment first, that can be done using virtualenv or conda is you use anaconda.&lt;/p&gt;
&lt;h4&gt;
  
  
  Using virtualenv
&lt;/h4&gt;


&lt;div class="highlight"&gt;&lt;pre class="highlight shell"&gt;&lt;code&gt;virtualenv &lt;span class="nt"&gt;--system-site-packages&lt;/span&gt; &lt;span class="nt"&gt;-p&lt;/span&gt; python3 ~/path/to/folder
&lt;span class="nb"&gt;source&lt;/span&gt; ~/path/to/folder/bin/activate
pip &lt;span class="nb"&gt;install &lt;/span&gt;keras jupyter numpy matplotlib
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;h4&gt;
  
  
  Using conda
&lt;/h4&gt;


&lt;div class="highlight"&gt;&lt;pre class="highlight shell"&gt;&lt;code&gt;conda create &lt;span class="nt"&gt;-n&lt;/span&gt; keras &lt;span class="nv"&gt;python&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;3.6.7 &lt;span class="c"&gt;#use any python3 version&lt;/span&gt;
conda activate keras
conda &lt;span class="nb"&gt;install &lt;/span&gt;keras jupyter numpy matplotlib
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;


&lt;p&gt;Now if you don't have any backends installed already, keras will use tensorflow backend.&lt;br&gt;
Numpy and Matplotlib are the libraries that will help us in faster matrix/tensor operations and plotting respectively.&lt;br&gt;
Now to show the basics of keras (very basics) we will use the example of fashion-mnist classification problem using a fully-connected neural network architecture. Now if you are unable to understand what these terms mean you should either take a basic deeplearning course or stick around for the fun!&lt;/p&gt;
&lt;h3&gt;
  
  
  Prerequisites
&lt;/h3&gt;

&lt;p&gt;These are the things you will need to follow along:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Basic python&lt;/li&gt;
&lt;li&gt;Basic deeplearning (for understanding the terminologies)&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Now assuming you searched for keras and got here, you probably know both of those things, so lets move on.&lt;/p&gt;
&lt;h3&gt;
  
  
  Programming
&lt;/h3&gt;

&lt;p&gt;Now assuming you are in the same virtual environment where keras and jupyter are installed, type the following:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight shell"&gt;&lt;code&gt;jupyter notebook
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;This will open a new tab running a jupyter server. Jupyter is going to be your best friend for all the machine learning and deeplearning stuff due to its features which allow easy and fast experimentation which is very necessary in the field of deeplearning.&lt;br&gt;
Next click on the new icon and select python3. This will open a new jupyter notebook in a new tab.&lt;/p&gt;
&lt;h4&gt;
  
  
  Description
&lt;/h4&gt;

&lt;p&gt;Now the network that we will implement here will be:&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--YkYEo1x4--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://thepracticaldev.s3.amazonaws.com/i/1o5gcuhpckov58vocx2s.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--YkYEo1x4--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://thepracticaldev.s3.amazonaws.com/i/1o5gcuhpckov58vocx2s.png" alt=""&gt;&lt;/a&gt;&lt;br&gt;
Input-&amp;gt;Flatten-&amp;gt;Dense(1024)-&amp;gt;Dense(10)&lt;br&gt;
Flatten layer here squishes the 2D image into a 1D vector which is used to fully-connect the input features(in this case the pixel values) to the next layer. Dense layer means that each node in this layer is connected to each and every node of the previous layer(your simple neural network layer). Finally the output layer here predicts the type of clothing which is one out of the ten possible, therefore it is softmax layer. All the hidden layers are relu layers.&lt;/p&gt;
&lt;h4&gt;
  
  
  Program
&lt;/h4&gt;

&lt;p&gt;Import all the necessary modules that we will need.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="nn"&gt;numpy&lt;/span&gt; &lt;span class="k"&gt;as&lt;/span&gt; &lt;span class="n"&gt;np&lt;/span&gt;
&lt;span class="o"&gt;%&lt;/span&gt;&lt;span class="n"&gt;matplotlib&lt;/span&gt; &lt;span class="n"&gt;inline&lt;/span&gt;
&lt;span class="kn"&gt;from&lt;/span&gt; &lt;span class="nn"&gt;matplotlib&lt;/span&gt; &lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;pyplot&lt;/span&gt; &lt;span class="k"&gt;as&lt;/span&gt; &lt;span class="n"&gt;plt&lt;/span&gt;
&lt;span class="kn"&gt;from&lt;/span&gt; &lt;span class="nn"&gt;keras.models&lt;/span&gt; &lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;Sequential&lt;/span&gt;
&lt;span class="kn"&gt;from&lt;/span&gt; &lt;span class="nn"&gt;keras.layers&lt;/span&gt; &lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;Flatten&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;Dense&lt;/span&gt;
&lt;span class="kn"&gt;from&lt;/span&gt; &lt;span class="nn"&gt;keras.datasets&lt;/span&gt; &lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;fashion_mnist&lt;/span&gt;
&lt;span class="kn"&gt;from&lt;/span&gt; &lt;span class="nn"&gt;keras.utils&lt;/span&gt; &lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;to_categorical&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;Now hit Shift+Enter to execute the cell and create a new cell below the current.&lt;br&gt;
Now its time to load the dataset.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;train_x&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;train_y&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;test_x&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;test_y&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;fashion_mnist&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;load_data&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;This will load the training and test data in train_x, train_y, test_x and test_y. train_x and test_x contain examples(images) while train_y and test_y contain corresponding layer.&lt;br&gt;
In the next cell lets know the shape of these variables.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="k"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;train_x&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;shape&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;train_y&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;shape&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="k"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;test_x&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;shape&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;test_y&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;shape&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;From the output we see that training set contains 60000 examples whereas test contains 10000 examples, recall that test set is always smaller that the training set. Also we see that each image is of the size 28*28, i.e. each image is 2D tensor of size 28*28 where each cell contains a grayscale value.&lt;br&gt;
Now to see any of the training example in image form you can do this.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="n"&gt;plt&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;imshow&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;train_x&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;10&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt; &lt;span class="n"&gt;cmap&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s"&gt;'gray'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;Here we look at 10th training example, you can different numbers in the index or look in the test_x variable.&lt;br&gt;
Now we are at the data pre-processing stage where we transform the data in such a way that it is easier for neural-network to train on these examples.&lt;br&gt;
First we normalize training and test examples by dividing each example by 255 since, max value of any pixel can be 255. This will keep the values between 0 and 1.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="n"&gt;train_x&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;train_x&lt;/span&gt; &lt;span class="o"&gt;/&lt;/span&gt; &lt;span class="mf"&gt;255.0&lt;/span&gt;
&lt;span class="n"&gt;test_x&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;test_x&lt;/span&gt; &lt;span class="o"&gt;/&lt;/span&gt; &lt;span class="mf"&gt;255.0&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;Now we write two lines of code to one hot encode the training and test labels. One hot encoding is used almost everywhere to improve the performance of the neural network in the classification task. Suppose there is a label&lt;/p&gt;

&lt;h3&gt;
  
  
  &lt;center&gt;y = 0&lt;/center&gt;
&lt;/h3&gt;

&lt;p&gt;Then after one hot encoding it will be&lt;/p&gt;

&lt;h3&gt;
  
  
  &lt;center&gt;y = [0, 0, 0, 1, 0, 0, 0, 0, 0, 0]&lt;/center&gt;
&lt;/h3&gt;

&lt;p&gt;This allows us to use softmax activation which is the best choice to use when output is from a probability distribution.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="n"&gt;train_y&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;to_categorical&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;train_y&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="n"&gt;test_y&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;to_categorical&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;test_y&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;Next, its time to create the model discussed at the beginning of the section.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="n"&gt;model&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;Sequential&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
&lt;span class="n"&gt;model&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;add&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;Flatten&lt;/span&gt;&lt;span class="p"&gt;())&lt;/span&gt;
&lt;span class="n"&gt;model&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;add&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;Dense&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;1024&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;activation&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s"&gt;'relu'&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;
&lt;span class="n"&gt;model&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;add&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;Dense&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;10&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;activation&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s"&gt;'softmax'&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;This creates a sequential model meaning each layer is after the layer before it. This creates exactly the same model that we discusses above.&lt;br&gt;
After creating the model we have to compile the model to be able to train it.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="n"&gt;model&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nb"&gt;compile&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;optimizer&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s"&gt;'Adam'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
              &lt;span class="n"&gt;loss&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s"&gt;'categorical_crossentropy'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
              &lt;span class="n"&gt;metrics&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s"&gt;'accuracy'&lt;/span&gt;&lt;span class="p"&gt;])&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;This step defines an optimization algorithm for the model to use, in this case we will use Adam optimizer which used most of the times in deeplearning applications. List of other optimizers such as SGD, RMSprop, etc can be found on &lt;a href="https://keras.io"&gt;keras website&lt;/a&gt; also linked above.&lt;br&gt;
categorical_crossentropy is the loss function to use if you are doing a classification task and your neural-network output is more than one.&lt;br&gt;
And metrics 'accuracy' is passed to see the accuracy of each epoch after training and testing. An epoch is single pass through a neural network which consists of a forward pass and a backward pass in the network.&lt;br&gt;
After compiling the network we are ready to Train it. Ah Finally!&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="n"&gt;model&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;fit&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;train_x&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;train_y&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;epochs&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;10&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;We train it for 10 epochs. You can try different numbers to experiment.&lt;br&gt;
After training accuracy of this network is about 91% which is pretty good for a simple and small network like this.&lt;br&gt;
But we should always evaluate our network on test set before becoming too happy about the training accuracy.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="n"&gt;model&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;evaluate&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;test_x&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;test_y&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;Evaluating on the test set gives about 89% accuracy. Again this test accuracy is pretty good for a simple network like this.&lt;br&gt;
Now there are ways to improve the performance of the network such as&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;using regularization&lt;/li&gt;
&lt;li&gt;dropout&lt;/li&gt;
&lt;li&gt;building more deeper network&lt;/li&gt;
&lt;li&gt;training for a longer time
and many more. But that will be a lot for a beginner post to include those methods.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  After this
&lt;/h2&gt;

&lt;p&gt;After this you can check some online deeplearning courses on coursera or any other online course whichever makes you understand it better.&lt;br&gt;
I would recommend that you practice your skills regularly, there is huge amount of free datasets available online which you can download and try to train a neural-network on that.&lt;/p&gt;

&lt;h4&gt;
  
  
  Finally, Thanks for reading!
&lt;/h4&gt;

</description>
      <category>deeplearning</category>
      <category>python</category>
      <category>keras</category>
      <category>introduction</category>
    </item>
  </channel>
</rss>
