Loading...

Follow Digital Asif - Digital Marketing Blog on Feedspot

Continue with Google
Continue with Facebook
or

Valid
The Second Machine Age: Work, Progress and Prosperity in a Time of Brilliant Technologies by Erik Brynjolfsson and Andrew McAfee

In recent years, Google’s autonomous cars have logged thousands of miles on American highways and IBM’s Watson trounced the best human Jeopardy! players. Digital technologies—with hardware, software, and networks at their core—will in the near future diagnose diseases more accurately than doctors can, apply enormous data sets to transform retailing, and accomplish many tasks once considered uniquely human.

In The Second Machine Age MIT’s Erik Brynjolfsson and Andrew McAfee—two thinkers at the forefront of their field—reveal the forces driving the reinvention of our lives and our economy. As the full impact of digital technologies is felt, we will realize immense bounty in the form of dazzling personal technology, advanced infrastructure, and near-boundless access to the cultural items that enrich our lives.

Available: Buy on Amazon

Getting started with Internet of Things by Cuno Pfister

What is the Internet of Things? It’s billions of embedded computers, sensors and actuators all connected online. If you have basic programming skills, you can use these powerful little devices to create a variety of useful systemsósuch as a device that waters plants when the soil becomes dry. This hands-on guide shows you how to start building your own fun and fascinating projects.
Learn to program embedded devices using the .NET Micro Framework and the Netduino Plus board. Then connect your devices to the Internet with Pachube, a cloud platform for sharing real-time sensor data. All you need is a Netduino Plus, a USB cable, a couple of sensors, an Ethernet connection to the Internetóand your imagination.

Available: Buy on Amazon

IoT Inc: How Your Company Can Use the Internet of Things to Win in the Outcome Economy by Bruce Sinclair

This essential guide provides an in-depth look into IoT―how it works and how it is transforming business; methods for seeing your own business, customers, and competitors through the lens of IoT, and a deep dive into how to develop and implement a powerful IoT strategy.

IoT isn’t a new business trend. It’s the new way of business. Period. The IoT wave is heading for your industry. You can either meet it head-on, and ride it to success, or you can turn your back and let it swamp you.

This is your playbook for transforming your company into a major player in the IoT Outcome economy.

Available: Buy on Amazon

The Silent Intelligence by Daniel Kellmereit

The Silent Intelligence is a book about the Internet of Things. We talk about the history, trends, technology ecosystem and future of Connected Cities, Connected Homes, Connected Health and Connected Cars. We also discuss the most exciting growth areas for entrepreneurs and venture capital investors. We share exciting stories and unique opinions of more than 30 industry veterans, experts and visionaries from Google, Ericsson, AT&T, Qualcomm, SAP, MIT, Jawbone and many others. We called this book The Silent Intelligence because most of the activity and growth in the space so far has been outside of mainstream visibility. Our aim is to help executives, entrepreneurs, investors and everybody who is interested in this topic, better understand the opportunities and challenges of the Internet of Things. We also hope that the new growth opportunities discussed in this book will be as exciting to you as they are to us.

Available: Buy on Amazon

Building the Internet of Things by Maciej Kranz

Connect your organization to the Internet of Things with solid strategy and a proven implementation plan

Building Internet of Things provides front-line business decision makers with a practical handbook for capitalizing on this latest transformation. Focusing on the business implications of Internet of Things (IoT), this book describes the sheer impact, spread, and opportunities arising every day, and how business leaders can implement IoT today to realize tangible business advantages. The discussion delves into IoT from a business, strategy and organizational standpoint, and includes use-cases that illustrate the ripple effect that this latest disruption brings; you’ll learn how to fashion a viable IoT plan that works with your organization’s strategy and direction, and how to implement that strategy successfully by integrating IoT into your organization tomorrow.

Available: Buy on Amazon

The Internet of Things by Samuel Greengard

A guided tour through the Internet of Things, a networked world of connected devices, objects, and people that is changing the way we live and work.

We turn on the lights in our house from a desk in an office miles away. Our refrigerator alerts us to buy milk on the way home. A package of cookies on the supermarket shelf suggests that we buy it, based on past purchases. The cookies themselves are on the shelf because of a “smart” supply chain. When we get home, the thermostat has already adjusted the temperature so that it’s toasty or bracing, whichever we prefer. This is the Internet of Things―a networked world of connected devices, objects, and people. In this book, Samuel Greengard offers a guided tour through this emerging world and how it will change the way we live and work.

Available: Buy on Amazon

The Amazon Way: 14 Leadership Principles Behind the World’s Most Disruptive Company by John Rossman

Peppered with humorous and enlightening firsthand anecdotes from the author’s career at Amazon, this revealing business guide is also filled with the valuable lessons that have served Jeff Bezos’s “everything store” so well—providing expert advice for aspiring entrepreneurs, CEOs, and investors alike.

In just twenty years, Amazon.com has gone from a start-up internet bookseller to a global company revolutionizing and disrupting multiple industries, including retail, publishing, logistics, devices, apparel, and cloud computing.

But what is at the heart of Amazon.com’s rise to success? Is it the tens of millions of items in stock, the company’s technological prowess, or the many customer service innovations like “one-click”?

As a leader at Amazon who had a front-row seat during its formative years, John Rossman understands the iconic company better than most. From the launch of Amazon’s third-party seller program to their foray into enterprise services, he witnessed it all—the amazing successes, the little-known failures, and the experiments whose outcomes are still in doubt.

Available: Buy on Amazon

Enterprise IoT by Dirk Slama, Frank Puhlmann, Jim Morrish and Rishi M Bhatnagar 

Current hype aside, the Internet of Things will ultimately become as fundamental as the Internet itself, with lots of opportunities and trials along the way. To help you navigate these choppy waters, this practical guide introduces a dedicated methodology for businesses preparing to transition towards IoT-based business models.

With a set of best practices based on case study analysis, expert interviews, and the authors’ own experience, the Ignite | IoT Methodology outlined in this book delivers actionable guidelines to assist you with IoT strategy management and project execution. You’ll also find a detailed case study of a project fully developed with this methodology.

Available: Buy on Amazon

Trillions by Peter Lucas, Joe Ballay and Mickey McManus

Written by the leaders of one of America’s leading pervasive computing design firms, this book gives a no-holds-barred insiders’ account of both the promise and the risks of the age of Trillions. It is also a cautionary tale of the head-in-the-sand attitude with which many of today’s thought-leaders are at present approaching these issues. Trillions is a field guide to the future–designed to help businesses and their customers prepare to prosper, in the information.

Available: Buy on Amazon

Mastering Internet of Things: Design and create your own IoT applications using Raspberry Pi 3 by Peter Waher This book focuses on creating applications and services for the Internet of Things. Further, you will learn to create applications and services for the Internet of Things. You will be discover various interesting projects and understand how to publish sensor data, control devices, and react to asynchronous events using the XMPP protocol. The book also introduces chat, to interact with your devices. You will learn how to automate your tasks by using Internet of Things Service Platforms as the base for an application. You will understand the subject of privacy, requirements they should be familiar with, and how to avoid violating any of the important new regulations being introduced.

Available: Buy on Amazon

Designing Connected Products by Claire Rowland, Elizabeth Goodman, Martin CharlierAlfred Lui and Ann Light

This book provides experienced UX designers and technologists with a clear and practical roadmap for approaching consumer product strategy and design in this novel market. By drawing on the best of current design practice and academic research, Designing Connected Products delivers sound advice for working with cross-device interactions and the complex ecosystems inherent in IoT technology.

Available: Buy on Amazon

The Amazon Way on IoT by John Rossman, Greg Shaw and Tucker Shouse

The Amazon Way on IoT explains how the combination of sensors, cloud computing and machine learning can be used to improve customer experiences, drive operational improvements and build new business models. Rossman offers:
– Guidance through the maze of emerging technologies, customer experiences, and business models, to arrive at a recipe just right for your organization
– Key methods to success from Amazon’s master playbook such as creating seamless customer experiences, process improvement and new business models and utilizing tools such as sensors, machine learning and cloud computing
– Approaches to help you tackle the technology, business and internal challenges in innovating with the internet of things.
Renowned Harvard business professor Michael Porter describes the IoT as the backbone for a third-wave of technology-led innovation and digital disruption.

Available: Buy on Amazon

Precision: Principles, Practices, and Solutions for the Internet of Things by Timothy Chou

You may not be sure why your coffee pot should talk to your toaster, but precision technology powering an industrial Internet of Things has the potential to reshape the planet. To help clarify, Dr. Timothy Chou has created Precision to introduce us to the basics of the industrial Internet of Things (IoT). The first part – Precision: Principles and Practices – introduces a vendor-neutral, acronym-free framework. Dr. Chou then discusses the framework’s fundamental principles and these principles put into practice. The second part –..

  • Show original
  • .
  • Share
  • .
  • Favorite
  • .
  • Email
  • .
  • Add Tags 

Over the next decade, machine learning is poised to transform every industry.

Artificial intelligence (AI) signals the arrival of the 4th Industrial Revolution. Machine learning is at the base of this technology feeding, driving and providing solutions for the inevitable disruption that follows.

Machine learning and AI are much more than normal technological advances. 

This new technology will link unrelated industries and forge new synergies that disrupt every existing industry. Along the way, it will create entirely new industries and previously unseen jobs.

Game Changing Numbers

Research shows that artificial intelligence can increase productivity 40 percent by 2035, driving profit improvement of up to 38 percent. 

Wall Street analysts are projecting 15.7 trillion dollars in AI-driven GDP growth by the year 2030, an amount larger than the GDP of China and India together.

Machine learning has the potential to reduce supply system errors by 50 percent, reduce administration costs up to 40 percent and cut transportation costs 10 percent. 

While most industries are open to incorporating AI, numbers like these force manufacturing to pay special attention.

The automotive industry has rapidly adopted AI into nearly every aspect of the business. From human resources to production lines, this adoption has been driven by lack of skilled labor, shortage of engineers and skyrocketing costs for elements like energy and lawsuits.

The Human Factor

Labor is one of the biggest costs for automakers and other manufacturers. These costs are not just in wages. Management, redesigning systems for worker safety and constant training are more expensive than paychecks.

Some of these costs can be reduced through an unusual form of deep machine learning called cognitive intelligence. This branch of machine learning replicates human reasoning within defined limits.

Manufacturers are using cognitive AI to replace live help desks. Other uses include pattern recognition in insurance or injury data to spot troublesome patterns before injury or lawsuit problems become costly.

The automakers were some of the first manufacturers to adopt artificial intelligence to manage robotic car building lines. 

Machine learning is applicable to quality control, inspection and slowing or speeding the assembly line. Changes can be made to account for delays from parts suppliers or to adjust to increasing order rates.

Henry Ford’s original moving assembly line revolutionized entire industries, not just automobile manufacturing. Now manufacturers see a similar level of disruption from the effects of AI and machine learning. 

Artificial intelligence, robotics, and automation are frequently seen as threatening human jobs. In reality, humans are freed to perform tasks that are less dangerous or more complex, resulting in higher pay. 

New jobs are also created to install, maintain, program and monitor robotic or AI installations.

Logistics Applications

Combining elements of machine learning like asset management, rules compliance, diagnostics and forecasting, cognitive AI is streamlining logistics. 

Train scheduling, ordering, load tracking, and dealer stock checks are all common uses for cognitive AI in the automotive industry today.

Monitoring for continuous improvement in both manufacturing and business processes can reduce delays and overhead. 

This is making for leaner, demand-based car design, production, and marketing.

Software and Controls Development

In today’s manufacturing, the software is pervasive throughout the process. Hiring, office work, and forecasting are just a few of the mundane business-side operations that have required software for decades. 

Nowadays there are tasks like operating the assembly line, powering robots at welding stations, parts retrievers and facility environments as well.

The automakers were the first corporations to use computer-aided design (CAD) and systems integration. 

That’s never changed and continues with even deeper involvement and integration today. 

In today’s factories, a change made in the accounting department to save money on a part will change 3D design drawings to reflect the parts change as well. 

Revisions to CAD designs can be automatically checked for safety requirements, efficiency differences, cost changes and regulatory compliance within seconds.

Systems can even check math against engineering or regulatory requirements and notify engineers that human intervention is needed in the process. 

Companies like IBM, Apple and Microsoft have used machine learning for years to replace bits of code or to simulate program changes. 

Manufacturers use custom software for their assembly lines and design studios. They have the same opportunities for machine learning as software companies do.

Transportation

Transportation affects manufacturing in several ways. 

The most obvious is in bringing materials to the factory and delivering finished goods to distributors. Clearly, machine learning is ready to make huge contributions in the form of load scheduling and tracking.

However, recent trends in self-driving cars and trucks will also have huge impacts on factory operations. 

Trucks can drive themselves to whichever dock is preferable and call automated unloading equipment to drop the load. Inside the factory, shuttles can pick up and deliver to and from the assembly line autonomously. 

Self-driving forklifts make efficient use of expensive floor space. In the marketplace, self-driving cars are inching ever closer to the showroom. 

Machine learning can deliver data from the real world as cars are operating, allowing informed decisions by factory software for cost, reliability and safety improvements.

In Conclusion

Artificial intelligence, machine learning and automation have transformed not only the assembly line but the factory around it, the warehouse that feeds it and the office that makes decisions about it. 

Soon, the outside world that delivers raw materials and buys the products will also be disrupted and things will never be the same.

Note: This is a guest post, and opinion in this article is of the guest writer. If you have any issues with any of the articles posted at www.marktechpost.com please contact at asif@marktechpost.com 


The post How Machine Learning Has Disrupted The Manufacturing Industry appeared first on MarkTechPost.

  • Show original
  • .
  • Share
  • .
  • Favorite
  • .
  • Email
  • .
  • Add Tags 

Exploratory Data Analysis is a method of uncovering important relationships between the variables by using Graphs, plots, and tables. Exploratory Data Analysis (EDA) is a very useful technique especially when you are working with the large unknown dataset. It allows you to investigate the interesting relationships between the variables, study the different subsets of data to unlock the different patterns in the data.

In this blog post, we will discuss how to perform exploratory data analysis by creating awesome visualizations using matplotlib and seaborn by taking a real-world data set.

Import Libraries

For data visualization, we will using these two libraries:

  • matplotlib – Matplotlib is a Python 2D plotting library which produces publication quality figures in a variety of hardcopy formats and interactive environments across platforms.
  • seaborn – Seaborn is a Python data visualization library based on matplotlib. It provides a high-level interface for drawing attractive and informative statistical graphics.
#import the libraries
import matplotlib.pyplot as plt
import seaborn as sns
%matplotlib inline #to display graphs inline of jupyter notebook
DataSet

For this analysis, we will be using Zomato Bangalore Restaurants dataset present on kaggle. The dataset contains all the details of the restaurants listed on Zomato website as of 15th March 2019.

About Zomato

Zomato is an Indian restaurant search and discovery service founded in 2008 by Deepinder Goyal and Pankaj Chaddah. It currently operates in 24 countries. It provides information and reviews of restaurants, including images of menus where the restaurant does not have its own website and also online delivery.

Source: Zomato Data Context

The basic idea of analyzing the Zomato dataset is to get a fair idea about the factors affecting the establishment of different types of restaurants at different places in Bengaluru. This Zomato data aims at analyzing demography of the location. Most importantly it will help new restaurants in deciding their theme, menus, cuisine, cost, etc for a particular location. It also aims at finding similarity between neighborhoods of Bengaluru on the basis of food.

1. Load the Data

We will use pandas to read the dataset.

import pandas as pd
#load the data
zomato_data = pd.read_csv("../input/zomato.csv")
zomato_data.head() #looking at first five rows of the data
2. Basic Data Understanding

Let’s start with basic data understanding by checking the data types of the columns in which we are interested to work with.

#get the datatypes of the columns
zomato_data.dtypes

Only the variable votes is read as an integer, remaining 16 columns are read as objects. So the variables like rating, approx_cost(for two people) should be changed to integer if we want to perform any analysis on them.

If you want to get the list of all the columns present in the dataset:

zomato_data.columns #get the list of all the columns
3. Data Cleaning & Data Manipulation

In this section, we will discuss some of the basic data cleaning techniques like checking for duplicate values & handling missing values. Apart from data cleaning, we will also discuss some of the manipulation techniques like changing the data type of the variables, dropping unwanted variables and renaming the columns for convenience.

#check for any duplicate values
zomato_data.duplicated().sum()

There are no duplicate values present in this dataset.

#check for missing values
pd.DataFrame(round(zomato_data.isnull().sum()/zomato_data.shape[0] * 100,3), columns = ["Missing"])
Missing Data in Percentages.

The variable dish_liked as more than 54 % of missing data. If we drop the missing data, we would lose more than 50% of the data. To simplify the analysis, we will drop some of the columns that are not very useful like url, address and phone.

zomato_data.drop(["url", "address",  "phone"], axis = 1, inplace = True)

Renaming few columns for convenience

zomato_data.rename(columns={"approx_cost(for two people)": "cost_two", "listed_in(type)":"service_type", "listed_in(city)":"serve_to"}, inplace = True)

As we have seen earlier that the variable cost_two has data type object which we need to convert to integer so that we can analyze the variable.

#converting the cost_two variable to int.
zomato_data.cost_two = zomato_data.cost_two.apply(lambda x: int(x.replace(',','')))
zomato_data.cost_two = zomato_data.cost_two.astype('int') 

To convert the variable to an integer we could simply use astype('int') but in this scenario, this method would not work because of the presence of a comma in between the numbers, eg. 2,500. To avoid this kind of problem, we are using lambda and replace function to replace comma (,) with nothing and then convert to integer.

4. Visualization

In this section, we will analyze the data by creating multiple visualizations using seaborn and matplotlib. The entire code discussed in the article is present in this kaggle kernel.

a. Count Plot

Countplot is essentially the same as the barplot except that it shows the count of observations in each category bin using bars. In our dataset, let’s check the count of each rating category present.

#plot the count of rating.
plt.rcParams['figure.figsize'] = 14,7
sns.countplot(zomato_data["rate"], palette="Set1")
plt.title("Count plot of rate variable")
plt.show()

The rate variable follows near normal distribution with mean equal to 3.7. The rating for the majority of the restaurants lies within the range of 3.5-4.2. Very few restaurants (~350) has rated more than 4.8.

b. Joint Plot

Jointplot allows us to compare the two different variables and see if there is any relationship between these two variables. By using the Joint plot we can do both bivariate and univariate analysis by plotting the scatterplot (bivariate) and distribution plot (univariate) of two different variables in a single plotting grid.

#joint plot for 'rate' and 'votes'
sns.jointplot(x = "rate", y = "votes", data = zomato_data, height=8, ratio=4, color="g")
plt.show()

From the scatter plot, we can infer that the restaurant with a high rating has more votes. The distribution plot of the variable votes on the right side indicates that the majority of votes pooled lie in the bucket of 1000-2500.

c. Bar Plot

Barplot is one of the most commonly used graphic to represent the data. Barplot represents data in rectangular bars with length of the bar proportional to the value of the variable. We will analyze the variable location and see in which area most of the restaurants are located in Bangalore.

#analyze the number of restaurants in a location
zomato_data.location.value_counts().nlargest(10).plot(kind = "barh")
plt.title("Number of restaurants by location")
plt.xlabel("Count")
plt.show()
  • Show original
  • .
  • Share
  • .
  • Favorite
  • .
  • Email
  • .
  • Add Tags 

The tradeoff between convenience and privacy continues to grow in importance as technology becomes more intertwined in our lives. Tech giants like Facebook and Twitter have received backlash on how they handle data collected from users and the presence of targeted advertisements has raised even more questions for our online world. 

While we are all well aware of social media apps collecting our personal data, you may not be as educated on other devices you use every day. When traveling to a new restaurant, you will probably use a navigation app to plan your route and avoid traffic delays. Whether you use Google Maps or Waze, our map apps are using our location and behaviors to collect data on us as we travel. 

This visual created by The Zebra highlights the data that the most popular map apps collect on us, what they can infer and how that data can be used. 

Map apps most likely know:

  • Where you live
  • Places you’ve visited
  • How long you’ve stayed at businesses
  • Your typical travel patterns

Infographics Source: www.thezebra.com

  • Show original
  • .
  • Share
  • .
  • Favorite
  • .
  • Email
  • .
  • Add Tags 
Motivation

In the previous articles, we solved problems with numeric and categorical data, and we learned the different transformations needed for each. Regarding images, we investigated a simple hack that resizes each image into an array of pixels and feed it to the input layer. The approach worked well and we reached around 97% accuracy on MNIST dataset.

However, dealing with large images with more complex patterns is completely different. Scientists struggled to reach an acceptable performance to even classify a dog vs cat image. Images like that contain many features that are related in a specific way. For example: some set of pixels in a given order define an edge, a circle, a nose, a mouth, etc. Therefore, we need a special kind of layer that detects these relations.

Here comes the role of the convolution layer. It is a neural network layer that scans an image, and extracts a set of features from it. Normally, we would accumulate those layers to learn more complex features. This way, the first layers learn very basic features such as horizontal edges, vertical edges, lines, etc. The deeper we go the more complex become the features. Layers will then be able to combine low level features into high level ones. For example: edges and curves could be combined to detect shapes of different heads, noses, ears, etc.

Convolution layers made a really high impact on the whole machine and deep learning fields. It allowed us to automated very complex tasks with human-level performance or even outperform humans in some cases. So, pay close attention you are going to have a very powerful weapon in your arsenal.

Image Kernels

An kernel (or filter) is simply a small matrix applied to an image with the convolution operator.

The process is as follows:

  1. a small matrix of shape (k1, k2) slides over the input,
  2. applies a pairwise multiplication on the two matrices,
  3. the sum of the resulting matrix is taken and the result is put into the final matrix output

See the image for better clarification:

The convolution operator

Applying a filter to an image extracts some features from it. The following image shows how a simple kernel detects edges.

Image kernels

The question here is how to get those numbers inside the kernel? Well, why don’t we make the neural network learn the best kernels to classify a set of images? This is core concept behind convolutional neural networks. Convolutional layers act as automatic feature extractors that are learned from the data.

Problem Definition

In this article we will train a convolutional neural network to classify clothes types from the fashion MNIST dataset.

Fashion-MNIST is a dataset of Zalando’s article images consisting of a training set of 60,000 examples and a test set of 10,000 examples. Each example is a 28×28 grayscale image, associated with a label from 10 classes.

Image Source: https://github.com/zalandoresearch/fashion-mnist

The labels are:

Output Labels
Loading the Data

Again we will use Keras to download our data.

from keras.datasets import fashion_mnist
(X_train, y_train), (X_test, y_test) = fashion_mnist.load_data()
Preprocessing Data

We need to do three simple modifications to our data:

  1. Transform the y_train and y_test into one hot encoded versions
  2. Reshape our images into (width, height, number of channels). Since we are dealing with gray scale images the number of channels will be one
  3. Scale our images by dividing with 255
# to categorical
from keras.utils import to_categorical
y_train_final = to_categorical(y_train)
y_test_final = to_categorical(y_test)

# reshape
X_train_final = X_train.reshape(-1, 28, 28, 1) / 255.
X_test_final = X_test.reshape(-1, 28, 28, 1) / 255.
Building the Network

Building a convolutional neural network is not different that building a normal one. The one difference here is that we do not need to reshape our images, because convolutional layers work with 2D images.

from keras import models, layers

model = models.Sequential()
model.add(layers.Conv2D(8, (3, 3), activation='relu', input_shape=(28, 28, 1)))
model.add(layers.Flatten())
model.add(layers.Dense(128, activation='relu'))
model.add(layers.Dense(10, activation='softmax'))

model.compile('rmsprop', 'categorical_crossentropy', metrics=['acc'])

The only new thing here is the first layer and the Flattern layer. We use a Conv2D that is the 2D convolution layer for 2D images. The parameters are the following:

  1. The number of kernels/filters to learn. Here we used 32 kernels. Imagine that each one of these kernels will learn a simple feature like vertical edge detection, horizontal edge detection, etc
  2. The size of the kernel. Here we used a 3 by 3 matrix.
  3. The activation function applied to the final output
  4. The input shape where 28 is the image width and height and 1 is the number of channels (1 since it is a gray scale image, for RGB we use 3)

Since the output of a convolution is a multidimensional matrix, we need to reshape the output (as we did before with a regular neural network). The flatten layer here does the same, it unfolds the matrix into an array that is then fed to the next layer.

Flatten Layers

Note: We used a softmax output layer of 10 Dense connected neurons since we have 10 labels to learn.

Training the Network

As before, we just have to call the fit method:

history = model.fit(X_train_final, y_train_final, validation_split=0.2, epochs=3)
 Train on 48000 samples, validate on 12000 samples Epoch 1/3 48000/48000 [==============================] - 19s 395us/step - loss: 0.4352 - acc: 0.8480 - val_loss: 0.3410 - val_acc: 0.8805 Epoch 2/3 48000/48000 [==============================] - 16s 332us/step - loss: 0.3132 - acc: 0.8909 - val_loss: 0.3213 - val_acc: 0.8873 Epoch 3/3 48000/48000 [==============================] - 17s 362us/step - loss: 0.2845 - acc: 0.9016 - val_loss: 0.3122 - val_acc: 0.8931 

With a very simple convolutional network we were able to reach 90% accuracy. The network could be improved for sure by adding more advanced layers and maybe some regularization techniques, but we will keep this for later articles.

Challenge

Try training a simple neural network (do not use convolutions) on the same dataset. Report your results in the comments section below.

Final Thoughts

In this article we learned the very basics of convolutional neural networks. We learned that they are used to automatically extract image features to yield higher accuracy than the standard fully connected networks.

Note: This is a guest post, and opinion in this article is of the guest writer. If you have any issues with any of the articles posted at www.marktechpost.com please contact at asif@marktechpost.com 

The post Deep Learning with Keras – Part 5: Convolutional Neural Networks appeared first on MarkTechPost.

  • Show original
  • .
  • Share
  • .
  • Favorite
  • .
  • Email
  • .
  • Add Tags 

By 2050, driverless cars and mobility as a service will grow to $7 trillion worldwide. Driverless cars will save consumers 250 million hours of free time from behind the wheel, $234 billion in public costs will be saved by reducing accidents from human error, and driverless cars can eliminate 90% of traffic fatalities – saving over 1 million lives every year. So if driverless are so time and money saving there has to be a catch.

The main catch for AI driving is how they decide who to save in a crash – can AI think ethically and how does it decide who should live and who should die? Most people feel that driverless cars should save as many lives as possible, but very few were willing to buy a vehicle programmed to minimize harm, rather they prefer cars programmed to protect passengers at all costs. Driverless cars will save a lot of lives, but programming them to do so could slow their adoption into society and cost many more lives. Real life applications grow even more complex in an accident causing injuries but not fatalities and the AI will have to make many hard decisions.

Find out how driverless cars are advancing and how AI is making decisions here.


Source: Cyber Security Degrees

Note: This is a guest post, and opinion in this article is of the guest writer. If you have any issues with any of the articles posted at www.marktechpost.com please contact at asif@marktechpost.com 

The post How AI Makes The Tough Choices appeared first on MarkTechPost.

  • Show original
  • .
  • Share
  • .
  • Favorite
  • .
  • Email
  • .
  • Add Tags 

Feedforward neural networks are also known as Multi-layered Network of Neurons (MLN). These network of models are called feedforward because the information only travels forward in the neural network, through the input nodes then through the hidden layers (single or many layers) and finally through the output nodes.

Source: PadhAI

Traditional models such as McCulloch Pitts, Perceptron and Sigmoid neuron models capacity is limited to linear functions. To handle the complex non-linear decision boundary between input and the output we are using the Multi-layered Network of Neurons.

Outline

In this post, we will discuss how to build a feed-forward neural network using Pytorch. We will do this incrementally using Pytorch TORCH.NN module. The way we do that it is, first we will generate non-linearly separable data with two classes. Then we will build our simple feedforward neural network using PyTorch tensor functionality. After that, we will use abstraction features available in Pytorch TORCH.NN module such as Functional, Sequential, Linear and Optim to make our neural network concise, flexible and efficient. Finally, we will move our network to CUDA and see how fast it performs.

Note: This tutorial assumes you already have PyTorch installed in your local machine or know how to use Pytorch in Google Collab with CUDA support, and are familiar with the basics of tensor operations. If you are not familiar with these concepts kindly refer to my previous post linked below.

Rest of the article is structured as follows:

  • Import libraries
  • Generate non-linearly separable data
  • Feedforward network using tensors and auto-grad
  • Train our feedforward network
  • NN.Functional
  • NN.Parameter
  • NN.Linear and Optim
  • NN.Sequential
  • Moving the Network to GPU

If you want to skip the theory part and get into the code right away, Click here

Import libraries

Before we start building our network, first we need to import the required libraries. We are importing the numpy to evaluate the matrix multiplication and dot product between two vectors, matplotlib to visualize the data and from thesklearn package, we are importing functions to generate data and evaluate the network performance. Importing torch for all things related to Pytorch.

#required libraries
import numpy as np
import math
import matplotlib.pyplot as plt
import matplotlib.colors
import time
import pandas as pd
from sklearn.model_selection import train_test_split
from sklearn.metrics import accuracy_score, mean_squared_error, log_loss
from tqdm import tqdm_notebook 

from IPython.display import HTML
import warnings
from sklearn.preprocessing import OneHotEncoder
from sklearn.datasets import make_blobs

import torch
warnings.filterwarnings('ignore')
Generate non-linearly separable data

In this section, we will see how to randomly generate non-linearly separable data using sklearn.

#generate data using make_blobs function from sklearn.
#centers = 4 indicates different types of classes
data, labels = make_blobs(n_samples=1000, centers=4, n_features=2, random_state=0)
print(data.shape, labels.shape)

#visualize the data
plt.scatter(data[:,0], data[:,1], c=labels, cmap=my_cmap)
plt.show()

#splitting the data into train and test
X_train, X_val, Y_train, Y_val = train_test_split(data, labels, stratify=labels, random_state=0)
print(X_train.shape, X_val.shape, labels.shape)

To generate data randomly we will use make_blobs to generate blobs of points with a Gaussian distribution. I have generated 1000 data points in 2D space with four blobs centers=4 as a multi-class classification prediction problem. Each data point has two inputs and 0, 1, 2 or 3 class labels.

Visualize data using matplotlib

Once we have our data ready, I have used the train_test_split function to split the data for training and validation in the ratio of 75:25.

Feedforward network using tensors and auto-grad

In this section, we will see how to build and train a simple neural network using Pytorch tensors and auto-grad. The network has six neurons in total — two in the first hidden layer and four in the output layer. For each of these neurons, pre-activation is represented by ‘a’ and post-activation is represented by ‘h’. In the network, we have a total of 18 parameters — 12 weight parameters and 6 bias terms.

We will use map function for the efficient conversion of numpy array to Pytorch tensors.

#converting the numpy array to torch tensors
X_train, Y_train, X_val, Y_val = map(torch.tensor, (X_train, Y_train, X_val, Y_val))
print(X_train.shape, Y_train.shape)

After converting the data to tensors, we need to write a function that helps us to compute the forward pass for the network.

#function for computing forward pass in the network
def model(x):
    A1 = torch.matmul(x, weights1) + bias1 # (N, 2) x (2, 2) -> (N, 2)
    H1 = A1.sigmoid() # (N, 2)
    A2 = torch.matmul(H1, weights2) + bias2 # (N, 2) x (2, 4) -> (N, 4)
    H2 = A2.exp()/A2.exp().sum(-1).unsqueeze(-1) # (N, 4) #applying softmax at output layer.
    return H2

We will define a function model which characterizes the forward pass. For each neuron present in the network, forward pass involves two steps:

  1. Pre-activation represented by ‘a’: It is a weighted sum of inputs plus the bias.
  2. Activation represented by ‘h’: Activation function is Sigmoid function.

Since we have multi-class output from the network, we are using Softmax activation instead of Sigmoid activation at the output layer (second layer) by using Pytorch chaining mechanism. The activation output of the final layer is the same as the predicted value of our network. The function will return this value outside. So that we can use this value to calculate the loss of the neuron.

#function to calculate loss of a function.
#y_hat -> predicted & y -> actual
def loss_fn(y_hat, y):
     return -(y_hat[range(y.shape[0]), y].log()).mean()

#function to calculate accuracy of model
def accuracy(y_hat, y):
     pred = torch.argmax(y_hat, dim=1)
     return (pred == y).float().mean()

Next, we have our loss function. In this case, instead of the mean square error, we are using the cross-entropy loss function. By using the cross-entropy loss we can find the difference between the predicted probability distribution and actual probability distribution to compute the loss of the network.

Train our feed-forward network

We will now train our data on the feed-forward network which we created. First, we will initialize all the weights present in the network using Xavier initialization. Xavier Initialization initializes the weights in your network by drawing them from a distribution with zero mean and a specific variance (by multiplying with 1/sqrt(n)),

Since we have only two input features, we are dividing the weights by 2 and then call the model function on the training data with 10000 epochs and learning rate set to 0.2

#set the seed
torch.manual_seed(0)

#initialize the weights and biases using Xavier Initialization
weights1 = torch.randn(2, 2) / math.sqrt(2)
weights1.requires_grad_()
bias1 = torch.zeros(2, requires_grad=True)

weights2 = torch.randn(2, 4) / math.sqrt(2)
weights2.requires_grad_()
bias2 = torch.zeros(4, requires_grad=True)

#set the parameters for training the model
learning_rate = 0.2
epochs = 10000
X_train = X_train.float()
Y_train = Y_train.long()
loss_arr = []
acc_arr = []

#training the network
for epoch in range(epochs):
    y_hat = model(X_train)  #compute the predicted distribution
    loss = loss_fn(y_hat, Y_train) #compute the loss of the network
    loss.backward() #backpropagate the gradients
    loss_arr.append(loss.item())
    acc_arr.append(accuracy(y_hat, Y_train))

    with torch.no_grad(): #update the weights and biases
        weights1 -= weights1.grad * learning_rate
        bias1 -= bias1.grad * learning_rate
        weights2 -= weights2.grad * learning_rate
        bias2 -= bias2.grad * learning_rate
        weights1.grad.zero_()
        bias1.grad.zero_()
        weights2.grad.zero_()
        bias2.grad.zero_()

For all the weights and biases, we are setting requires_grad = True because we want to track all the operations performing on those tensors. After that, I have set the parameter values required for training the network and converted the X_train to float because the default tensor type in PyTorch is a float tensor. Because we are using Y_train as an index for another tensor while calculating the loss, I have converted it into a long tensor.

For each epoch, we will loop through the entire training data and call model function for the computation of forward pass. Once we compute the forward pass, we will apply the loss function on the output and call loss.backward() to propagate the loss backward into the network. loss.backward() updates the gradients of the model, in this case, weights and bias. We now use these gradients to update the weights and bias. We do this within the torch.no_grad() context manager because we need to ensure that there is no further expansion of the computation graph.

Set the gradients to zero, so that we are ready for the next loop. Otherwise, our gradients would record a running tally of all the operations that had happened (i.e. loss.backward()adds the gradients to whatever is already stored, rather than replacing them).

That’s it: we’ve created and trained a simple neural network entirely from scratch!. Let’s compute the training and validation accuracy of the model to evaluate the performance of the model and check for any scope of improvement by changing the number of epochs or learning rate.

Using NN.Functional

In this section, we will discuss how can refactor our code by taking advantage of PyTorch’s nn classes to make it more concise and flexible. First, we will import the torch.nn.functional into our namespace by using the following command.

import torch.nn.functional as F

This module contains a wide range of loss and activation functions. The only change we will do in our code is that instead of using the handwritten loss function we can use the inbuilt cross entropy function present in torch.nn.functional

loss = F.cross_entropy()

Putting it together

torch.manual_seed(0)
weights1 = torch.randn(2, 2) / math.sqrt(2)
weights1.requires_grad_()
bias1 = torch.zeros(2, requires_grad=True)
weights2 = torch.randn(2, 4) / math.sqrt(2)
weights2.requires_grad_()
bias2 = torch.zeros(4, requires_grad=True)

learning_rate = 0.2
epochs = 10000
loss_arr = []
acc_arr = []

for epoch in range(epochs):
    y_hat = model(X_train) #compute the predicted distribution
    loss = F.cross_entropy(y_hat, Y_train) #just replace the loss function with built in function
    loss.backward()
    loss_arr.append(loss.item())
    acc_arr.append(accuracy(y_hat, Y_train))

    with torch.no_grad():
        weights1 -= weights1.grad * learning_rate
        bias1 -= bias1.grad * learning_rate
        weights2 -= weights2.grad * learning_rate
        bias2 -= bias2.grad * learning_rate
        weights1.grad.zero_()
        bias1.grad.zero_()
        weights2.grad.zero_()
        bias2.grad.zero_()

Let’s confirm that our loss and accuracy are the same as before by training the network with same number of epochs and learning rate.

  • Loss of the network using handwritten loss function: 1.54
  • Loss of the network using inbuilt F.cross_entropy: 1.411
Using NN.Parameter

Next up, we’ll use nn.Module and nn.Parameter, for a clearer and more concise training loop. We will write a class FirstNetwork for our model which will subclass nn.Module. In this case, we want to create a class that holds our weights, bias, and method for the forward step.

Import torch.nn as nn
class FirstNetwork(nn.Module):
    def __init__(self):    
        super().__init__()
        torch.manual_seed(0)
        #wrap all the weights and biases inside nn.parameter()
        self.weights1 = nn.Parameter(torch.randn(2, 2) / math.sqrt(2))
        self.bias1 = nn.Parameter(torch.zeros(2))
        self.weights2 = nn.Parameter(torch.randn(2, 4) / math.sqrt(2))
        self.bias2 = nn.Parameter(torch.zeros(4))
    
    def forward(self, X):
        a1 = torch.matmul(X, self.weights1) + self.bias1
        h1 = a1.sigmoid()
        a2 = torch.matmul(h1, self.weights2) + self.bias2
        h2 = a2.exp()/a2.exp().sum(-1).unsqueeze(-1)
        return h2

The __init__ function (constructor function) helps us to initialize the parameters of the network but in this case, we are wrapping the weights and biases inside nn.Parameter. Since we are wrapping the weights and biases inside nn.Parameter they are automatically added to the list of its parameters.

Since we’re now using an object instead of just using a function, we first have to instantiate our model:

#we first have to instantiate our model
model = FirstNetwork() 

Next, we will write our training loop inside a function called fit that accepts the number of epochs and learning rate as its arguments. Inside the fit method we will call our model object model to execute the forward pass, but behind the scenes, Pytorch will call our forward method automatically.

def fit(epochs = 10000, learning_rate = 0.2):
    loss_arr = []
    acc_arr = []
    for epoch in range(epochs):
        y_hat = model(X_train) #forward pass
        loss = F.cross_entropy(y_hat, Y_train) #loss calculation
        loss_arr.append(loss.item())
        acc_arr.append(accuracy(y_hat, Y_train))
        loss.backward() #backpropagation
        with torch.no_grad():
            #updating the parameters
            for param in model.parameters():
                param -= learning_rate * param.grad
            model.zero_grad() #setting the gradients to zero   

In our training loop, instead of updating the values for each parameter by name, and manually zero out the grads for each parameter separately. Now we can take advantage of model.parameters() and model.zero_grad() (which are both defined by PyTorch for nn.Module) and update all the parameters of the model in one shot, to make those steps more concise and less prone to the error of forgetting some of our parameters.

One important point to note from the programming standpoint is that now we have successfully decoupled the model and fit function. In fact, you can see that there is nothing about the model, the fit function knows. It applies the same logic to whatever model is defined.

Using NN.Linear and Optim

In the previous sections, we are manually defining and initializing self.weights and self.bias, and computing forward pass this process is abstracted out by using Pytorch class nn.Linear for a linear layer, which does all that for us.

class FirstNetwork_v1(nn.Module):
    def __init__(self):
        super().__init__()
        torch.manual_seed(0)
        self.lin1 = nn.Linear(2, 2) #automatically defines weights and biases
        self.lin2 = nn.Linear(2, 4)
    
    def forward(self, X):
        a1 = self.lin1(X) #computes the dot product and adds bias
        h1 = a1.sigmoid()
        a2 = self.lin2(h1) #computes dot product and adds bias
        h2 = a2.exp()/a2.exp().sum(-1).unsqueeze(-1)
        return..
  • Show original
  • .
  • Share
  • .
  • Favorite
  • .
  • Email
  • .
  • Add Tags 

Everyone seems to talk about how Artificial Intelligence (AI) is coming for their jobs, and that freelancers will probably be worst hit, thanks to AI systems that can design, and build websites, generate code, write content, even produce videos, and music. However, the leading freelance marketplace Upwork recently concluded in a survey that AI is the second most sought after skill in freelancing. The same study also revealed that the relationship between businesses, and freelancers is set to change over the next few years, with more businesses looking for good solid talent, with not just generic know-how but very specific skills. 

They are increasingly open to remote workers and freelancers for their short and long term needs. 59% of managers said in the Upwork survey that they are looking to hire ‘flexible talent’ like freelancers, and other temporary talents, and this trend is only set to rise.

No AI project is the same for two companies. Each business needs custom solutions and freelancers can sit perfectly between the business goals and the technology. So what you need is a solid grip on the basics of AI and the resourcefulness to adapt to different business environments. To help you with that, here are 6 surefire ways to begin your freelancing career and excel in it.


1.  Specialize – Become Really Good At One Thing

This has been age-old advice given to freelancers in pretty much any field, and yet, new freelancers continue to get baffled at the prospect of limiting their expertise to a very niche skill set. Won’t you be better off being an all-rounder and catering to a wide range of clients? Why would you pick just one direction and limit yourself to clients of one kind only? 

Well, you should choose the latter, as it’s what highly paid smart freelancers do. Like we said earlier, AI is a self-learning discipline and most of the generic things that ‘all-round developers’ tend to do will be easily done and dusted by AI in the next year or two. There won’t be much of a demand for jack-of-all’s. Somebody who knows a bit of Python, a bit of TensorFlow, a bit of R and mostly, knows how to do the basic stuff will only attract clients at the shallow end of the pool. 

The high paying clients need specialized talent. They need someone who is extremely well versed with TensorFlow and can create customized solutions for their business, or someone who knows R like the back of his hand. Instead of marketing yourself as a run-of-the-mill AI professional, consider becoming a freelancer with established skills in algorithm development. Find the field you like the most and try to become the authority in it, by leaning everything there is to learn and taking up multiple projects of it. 

2. Seek Out an Internship 

No amount of learning AI can give you what a real project on real solutions to real problems can. Sure your dream as a freelancer is to call your own shots, work on your own time and basically, live the good life. An internship is pretty much at the opposite end of that spectrum, where you are constantly under pressure, being rushed for deadlines and being treated like a trainee who needs to run errands at all times. But, this step is crucial at the beginning of your career. 

You need to be acquainted with problems businesses deal with and what it takes to solve them at scale, in a defined timeline. You need to watch the experienced people go about chiseling new and custom solutions for legacy problems. 

You need to work in a competitive environment to hone your skills and most of all;  you need the proof you can show to future clients, that you have worked on some quality projects and have the skill and experience they need. An internship will help your resume get pulled out faster from the piles thereof and establish you as a credible AI professional

3. Participate in Kaggle Competitions 

Kaggle competitions can be your big breakthrough if you are skilled. Given the number of competitions open, you can pick one and work really hard at developing a fantastic solution for it. If you do a good job, you can not only win a handsome reward which can be a much needed financial aid at this stage, but also add some stars to your resume and gain valuable experience along the way. 

4. Maintain an Up to Date LinkedIn profile

You probably know this but we’ll reiterate just so you take a fresh look at your profile and jazz it up where needed. In the professional world, keeping up appearances translates to maintaining your LinkedIn profile. Something you updated six months ago and hasn’t added too much since then is less likely to attract any clients. 

Visit your profile regularly, use a good headshot and write a great bio that is professional with a dash of humor and neatly sums up your strengths. Add details of your work experience and projects, follow influential people from the industry and interact with some good relevant posts, so that they show up in your activity. All of this goes on to establish you as someone who is in tune with the trends, is super aware and knows where the world of AI is headed. 

5. Create Some Content Yourself

Okay, you’re an AI freelancer not a content creator, we get it. So you don’t have to create a blog or a YouTube channel and post regularly. However, if you can, writing a blog post here and there or occasionally sharing your knowledge and experience in the form of online content and establish you as an authority in the field. 

You can write occasional guest posts for leading industry blogs as a starting point. These serve as fantastic add-ons when applying for freelancing jobs. You could also create a website, as most freelancers like to, to showcase your skills and attract clients. 

6.  Start with Freelance Marketplaces

This isn’t general advice, and definitely not for long term. However, if you are just desperate to begin working and get your first client, you can always go to Upwork or Truelance and other freelance marketplaces to look for jobs that fit and apply. Choose the jobs you apply for carefully and do not fall into the downward spiral of bidding. 

Pick clients who have a history of paying well, quote a rate that’s fit for your time and stick to it. There are good clients on these sites, though few and far in between. Seek them out and you can find rewarding opportunities. Once you begin, look to branch out and use this experience to prospect other clients. 

Wrapping Up

If you’re an AI enthusiast looking to become a well-paid freelancer in this exciting field, there are several different ways to approach this. The opportunities are immense. AI itself, and its sub-sections like machine learning are increasingly becoming a business requirement and everyone from small startups to large corporations are deploying technologies like chatbots, big data analytics, voice recognition, deep learning, and so much more. 

You could tell that AI is the next big green pasture for freelancers. Smart freelancers willing to up-skill themselves by continuously learning, and staying on top of the latest trends are close to being immune to the AI-induced job drain.

Note: This is a guest post, and opinion in this article is of the guest writer. If you have any issues with any of the articles posted at www.marktechpost.com please contact at asif@marktechpost.com 

The post 6 Surefire Ways to Land Rewarding Freelance Job in AI appeared first on MarkTechPost.

  • Show original
  • .
  • Share
  • .
  • Favorite
  • .
  • Email
  • .
  • Add Tags 

Theorized by one of science’s greatest minds Nikola Tesla in 1926, the concept of a realistic “World Wireless System” was born. Describing the possibilities of instantaneous, wireless, digital communication, Tesla essentially put forward a prediction of modern-day smartphones running off of WiFi. Though it would be decades before this vision truly came to life.

While WiFi and the Internet itself that we know today was only popularized in the 1990s, the technology behind it had been in constant development. Unsung visionary and inventor Hedy Lamarr built and patented FHSS technology with the intention of guiding torpedos during wartime undetected, all while the world was mesmerized by her grace on the Hollywood silver screen. Thirty years later Norman Abramson of the University of Hawaii developed ALOHAnet, the first network to use radio communications to allow computers to send and receive data transmissions as soon as it becomes available. By 1999, the term “Wi-Fi” itself was trademarked by the Wi-Fi Alliance, since then growing in speed capabilities 650x.

What’s next for your home WiFi? By 2020, there will be 20 billion IoT devices, all vying for reliable connections and it’s WiFi 6 that will pick up the slack. This infographic details the past developments for our wireless connections and what we can learn from each iteration to help us look forward to more advancements to come.

Note: This is a guest post, and opinion in this article is of the guest writer. If you have any issues with any of the articles posted at www.marktechpost.com please contact at asif@marktechpost.com 

The post The Next Generation Of WiFi Is Here appeared first on MarkTechPost.

  • Show original
  • .
  • Share
  • .
  • Favorite
  • .
  • Email
  • .
  • Add Tags 
Classification Introduction

Welcome to Part 3 of Deep Learning with Keras. The goal of this series is to get you familiar with the famous deep learning library Keras and how to use it for building various deep learning models. In this part we will focus on classification. Generally speaking, classification is the process of identifying to which predefined set of categories a new observation belongs.

Building a classification neural network requires some tweaks to what we have done before. Let us investigate the process next.

Problem Definition

Consider a set of images containing handwritten digits from 0 to 9, our goal is to train a model that takes each picture and predict the correct digit it corresponds to. The data we are going to use is the famous MNIST database of handwritten digits. Keras already has this data available and we can load it as in the following:

from keras.datasets import mnist
(X_train, y_train), (X_test, y_test) = mnist.load_data()

Make sure you have an Internet connection the first time you run the above code since Keras will download the data from the web.

The obtained data is a set of 28*28 gray-scale images with 60000 training data and 10000 testing data. Each label is a number from 0-9 that represents the written digit in each image. The figure below shows a snapshot of the data:

Data Preprocessing

As discussed in a previous article, we need to preprocess our image data. The following code reshapes and scales the images according to the techniques introduced here.

X_train_final = X_train.reshape(-1, 28*28) / 255.
X_test_final = X_test.reshape(-1, 28*28) / 255.

In addition to modifying images, we need to transform out labels to one-hot-encoded presentations in order to break the existing nominal relation. This is very simple in Keras and could be done as what follows:

from keras.utils import to_categorical
y_train_final = to_categorical(y_train)
y_test_final = to_categorical(y_test)

See the difference before and after encoding:

Building the Network

Time to start building the network. We will build a simple one with one hidden layer and a special output layer that we will talk about soon. Let us start:

from keras import models, layers

model = models.Sequential()

model.add(layers.Dense(512, activation='relu', input_shape=(28*28, )))

model.add(layers.Dense(10, activation='softmax'))

model.compile('rmsprop', 'categorical_crossentropy', metrics=['acc'])

We have two new things here: 1) activation = ‘softmax’ and loss=’categorical_crossentropy’.

Softmax is a special activation function that transforms the output into probability values of each class. Therefore, with Dense(10) we will have 10 neurons each representing the probability of a given digit.

Categorical Cross-entropy is simply a loss function that calculates the error between the predicted digit and the actual one. We use categorical cross-entropy when we have 3 or more classes and binary cross-entropy when we have 2 classes.

Training the Model

You should be familiar with the training process. We simply have to call the fit function passing our data:

history = model.fit(X_train_final, y_train_final, epochs=10, batch_size=128, validation_split=0.2)

Here we ran the model for 10 epochs with 20% validation data. The results are the following:

Train on 48000 samples, validate on 12000 samples
Epoch 1/10 48000/48000 [==============================] - 5s 94us/step - loss: 0.2863 - acc: 0.9181 - val_loss: 0.1481 - val_acc: 0.9587
Epoch 2/10 48000/48000 [==============================] - 5s 102us/step - loss: 0.1184 - acc: 0.9654 - val_loss: 0.1040 - val_acc: 0.9702
Epoch 3/10 48000/48000 [==============================] - 5s 98us/step - loss: 0.0768 - acc: 0.9769 - val_loss: 0.0860 - val_acc: 0.9748
Epoch 4/10 48000/48000 [==============================] - 5s 100us/step - loss: 0.0548 - acc: 0.9836 - val_loss: 0.0963 - val_acc: 0.9713
Epoch 5/10 48000/48000 [==============================] - 5s 102us/step - loss: 0.0407 - acc: 0.9879 - val_loss: 0.0868 - val_acc: 0.9752
Epoch 6/10 48000/48000 [==============================] - 5s 114us/step - loss: 0.0303 - acc: 0.9911 - val_loss: 0.0875 - val_acc: 0.9763
Epoch 7/10 48000/48000 [==============================] - 5s 100us/step - loss: 0.0230 - acc: 0.9932 - val_loss: 0.0861 - val_acc: 0.9772
Epoch 8/10 48000/48000 [==============================] - 5s 102us/step - loss: 0.0179 - acc: 0.9948 - val_loss: 0.0844 - val_acc: 0.9778
Epoch 9/10 48000/48000 [==============================] - 5s 95us/step - loss: 0.0137 - acc: 0.9959 - val_loss: 0.0840 - val_acc: 0.9793
Epoch 10/10 48000/48000 [==============================] - 4s 88us/step - loss: 0.0101 - acc: 0.9973 - val_loss: 0.0879 - val_acc: 0.9797

Impressive! We reached a 97% validation accuracy with a model as simple as this. Let us evaluate the model on the test set.

Model Evaluation
model.evaluate(X_test_final, y_test_final)
# output 
# [0.07102660850500979, 0.9799]

Very good results. 0.07 loss and again 97% accuracy.

Final thoughts

In this article we covered classification and to implement it with Keras. We trained a model to predict handwritten digits and succeeded to reach a 97% accuracy. If you enjoyed the article please feel free to share it with your network. In case you have any questions do not hesitate to leave a comment below.

Note: This is a guest post, and opinion in this article is of the guest writer. If you have any issues with any of the articles posted at www.marktechpost.com please contact at asif@marktechpost.com 

The post Deep Learning with Keras – Part 4: Classification appeared first on MarkTechPost.

Read for later

Articles marked as Favorite are saved for later viewing.
close
  • Show original
  • .
  • Share
  • .
  • Favorite
  • .
  • Email
  • .
  • Add Tags 

Separate tags by commas
To access this feature, please upgrade your account.
Start your free month
Free Preview