Evolution of Cloud Computing
Evolution of Cloud Computing
Cloud computing is all about renting computing services. This idea first came in
the 1950s. In making cloud computing what it is today, five technologies played a
vital role. These are distributed systems and its peripherals, virtualization, web
2.0, service orientation, and utility computing.
• Distributed Systems:
Mainframes which first came into existence in 1951 are highly powerful
and reliable computing machines. These are responsible for handling
large data such as massive input-output operations. Even today these are
used for bulk processing tasks such as online transactions etc. These
systems have almost no downtime with high fault tolerance. After
distributed computing, these increased the processing capabilities of the
system. But these were very expensive. To reduce this cost, cluster
computing came as an alternative to mainframe technology.
• Cluster computing:
• Grid computing:
• Virtualization:
• Web 2.0:
• Service orientation:
• Utility computing:
It is a computing model that defines service provisioning techniques for
services such as compute services along with other major services such
as storage, infrastructure, etc which are provisioned on a pay-per-use
basis.
Thus, the above technologies contributed to the making of cloud computing.
Difference between Cloud Computing
and Grid Computing
Cloud Computing:
Cloud Computing is a Client-server computing architecture. In cloud
computing, resources are used in centralized pattern and cloud computing is
a high accessible service. It is a pay and use business means, in cloud
computing, the users pay for the use
Grid Computing:
Grid Computing is a Distributed computing architecture. In grid computing,
resources are used in collaborative pattern, and also in grid computing, the
users do not pay for use.
Let’s see the difference between cloud and grid computing which are given
below:
In cloud computing, the users pay While in grid computing, the users do
5. for the use. not pay for use.
Grid Computing
Grid Computing can be defined as a network of computers working together to
perform a task that would rather be difficult for a single machine. All machines on
that network work under the same protocol to act as a virtual supercomputer. The
task that they work on may include analyzing huge datasets or simulating
situations that require high computing power. Computers on the network
contribute resources like processing power and storage capacity to the network.
Grid Computing is a subset of distributed computing, where a virtual
supercomputer comprises machines on a network connected by some bus, mostly
Ethernet or sometimes the Internet. It can also be seen as a form of Parallel
Computing where instead of many CPU cores on a single machine, it contains
multiple cores spread across various locations. The concept of grid computing isn’t
new, but it is not yet perfected as there are no standard rules and protocols
established and accepted by people.
Working:
A Grid computing network mainly consists of these three types of machines
1. Control Node:
A computer, usually a server or a group of servers which administrates
the whole network and keeps the account of the resources in the
network pool.
2. Provider:
The computer contributes its resources to the network resource pool.
3. User:
The computer that uses the resources on the network.
When a computer makes a request for resources to the control node, the control
node gives the user access to the resources available on the network. When it is
not in use it should ideally contribute its resources to the network. Hence a normal
computer on the node can swing in between being a user or a provider based on
its needs. The nodes may consist of machines with similar platforms using the
same OS called homogeneous networks, else machines with different platforms
running on various different OSs called heterogeneous networks. This is the
distinguishing part of grid computing from other distributed computing
architectures.
For controlling the network and its resources a software/networking protocol is
used generally known as Middleware. This is responsible for administrating the
network and the control nodes are merely its executors. As a grid computing
system should use only unused resources of a computer, it is the job of the control
node that any provider is not overloaded with tasks.
Another job of the middleware is to authorize any process that is being executed
on the network. In a grid computing system, a provider gives permission to the
user to run anything on its computer, hence it is a huge security threat for the
network. Hence a middleware should ensure that there is no unwanted task being
executed on the network.
The meaning of the term Grid Computing has changed over the years, according to
“The Grid: Blueprint for a new computing infrastructure” by Ian Foster and Carl
Kesselman published in 1999, the idea was to consume computing power like
electricity is consumed from a power grid. This idea is similar to the current
concept of cloud computing, whereas now grid computing is viewed as a
distributed collaborative network. Currently, grid computing is being used in
various institutions to solve a lot of mathematical, analytical, and physics
problems.
Grid Computing:
2. Cluster Computing :
Serial
Number Category Cloud Computing Cluster Computing
Performing a
Providing on demand IT complex task in a
1. Goal resources and services. modular approach.
Specific assigned
Resource Specific assigned resources are resources are not
2. Sharing not shareable. shareable.
In Cluster
Computing there is
In cloud computing there is homogeneous
3. Resource type heterogeneous resource type. resource type.
Virtualization hardware and No virtualization
4. Virtualization software resources. resources.
Security through
node
Security through isolation can be credential can be
5. Security achieved. achieved.
Security
7. Requirement Very low Very high
Requires little
8. Maintenance Requires low maintenance. more maintenance.
More hardware
No hardware requirement requirement
9. Hardware physically. physically.
In Cluster
Computing Cluster
In Cloud Computing User oriented
13. Architecture chosen architecture. architecture
In cluster
Software In cloud computing application computing
15. Dependent domain independent software. application domain
dependent
software.
Sony PlayStation
16. Example Dropbox, Gmail clusters
2. Traditional Computing :
It is ability to access data anywhere at User can access data only on system in which
any time by user. data is stored.
Grid Computing :
2. Utility Computing :
It is of three types i.e., computational It is of two type i.e., Internal and external
grid, data grid, and collaborative grid. utility.
Distributed Computing:
Number of Server Cloud computing has Few Fog computing has Large number
Nodes number of server nodes. of server nodes.
Geographical
Distribution It is centralized. It is decentralized and distributed.
Dependence on the
quality of core Requires strong network Can also work in Weak network
network core. core.
Edge Computing
Computation takes place at the edge of a device’s network, which is known as
edge computing. That means a computer is connected with the network of the
device, which processes the data and sends the data to the cloud in real-time.
That computer is known as “edge computer” or “edge node”.
With this technology, data is processed and transmitted to the devices instantly.
Yet, edge nodes transmit all the data captured or generated by the device
regardless of the importance of the data.
Here Fog Computing was introduced and becomes an ideal solution.
Fog Computing
Fog computing is an extension of cloud computing. It is a layer in between the
edge and the cloud. When edge computers send huge amounts of data to the
cloud, fog nodes receive the data and analyze what’s important. Then the fog
nodes transfer the important data to the cloud to be stored and delete the
unimportant data or keep them with themselves for further analysis. In this way,
fog computing saves a lot of space in the cloud and transfers important data
quickly.
Cluster Computing:
A Computer Cluster is a local network of two or more homogeneous
computers.A computation process on such a computer network i.e. cluster is
called Cluster Computing.
Grid Computing:
Grid Computing can be defined as a network of homogeneous or
heterogeneous computers working together over a long distance to perform
a task that would rather be difficult for a single machine.
Difference between Cluster and Grid Computing:
2. Cluster Computing :
Cluster computing refers to the process of sharing the computation task to
multiple computers of the cluster. The number of computers are connected on a
network and they perform a single task by forming a Cluster of computers where
the process of computing is called as cluster computing.
Cluster Computing is a high performance computing framework which helps in
solving more complex operations more efficiently with a faster processing speed
and better data integrity. Cluster Computing is a networking technology that
performs its operations based on the principle of distributed systems.
The below figure illustrates a simple architecture of Cluster Computing –
Difference between Cloud Computing and Cluster Computing :
Serial
Number Category Cloud Computing Cluster Computing
Performing a
Providing on demand IT complex task in a
1. Goal resources and services. modular approach.
Specific assigned
Resource Specific assigned resources are resources are not
2. Sharing not shareable. shareable.
In Cluster
Computing there is
Resource In cloud computing there is homogeneous
3. type heterogeneous resource type. resource type.
Security
7. Requirement Very low Very high
Requires little
8. Maintenance Requires low maintenance. more maintenance.
More hardware
No hardware requirement requirement
9. Hardware physically. physically.
In Cluster
Computing Cluster
In Cloud Computing User oriented
13. Architecture chosen architecture. architecture
In cluster
computing
application domain
Software In cloud computing application dependent
15. Dependent domain independent software. software.
Sony PlayStation
16. Example Dropbox, Gmail clusters
Its main goal is to provide magnitude Its main goal is to attain economic
improvement in cost effective, dynamic viability and improve way of how
provisioning of IT services. computing devices are used.
It allows us to understand things that are It enables designs and optimizations that
very difficult to see or measure in real make it possible for us to enjoy
life. advantages of technology.
It is larger in size and very expensive as It is small in size and cost effective as
compared to embedded computers. compared to super computers.
It can be used for many things. It can be used for only one purpose.
Function of Computer
Computers
IOT Devices
Function of Computer
Computers
IOT Devices
•
After that in 2009, Google Play also started providing Cloud
Computing Enterprise Application as other companies will see the
emergence of cloud Computing they also started providing their
cloud services. Thus, in 2009, Microsoft launch Microsoft Azure and
after that other companies like Alibaba, IBM, Oracle, HP also
introduces their Cloud Services. In today the Cloud Computing
become very popular and important skill.
Advantages :
• It is easier to get backup in cloud.
• It allows us easy and quick access stored information anywhere and
anytime.
• It allows us to access data via mobile.
• It reduces both hardware ad Software cost, and it is easily
maintainable.
• One of the biggest advantage of Cloud Computing is Database
Security.
Disadvantages :
• It requires good internet connection.
• User have limited control on the data.
• Superposition –
In classical computing, bits have two possible states either zero or
one. In quantum computing, a qubit (short for “quantum bit”) is a unit
of quantum information—the quantum analogue to a classical bit.
Qubits have special properties that help them solve complex problems
much faster than classical bits. One of these properties
is superposition, which states that instead of holding one binary value
(“0” or “1”) like a classical bit, a qubit can hold a combination of “0” and
“1” simultaneously. Qubits have two possible outcomes zero or one but
those states are a superposition of zero and one. In the quantum world,
qubits don’t have to be in one of those states. It can be in any
proportion of those states. As soon as we measure its value it has to
decide whether it is zero or one. This is called superposition. It is the
ability of the quantum system to be in multiple states at the same time.
In classical computing for example there are 4 bits. The combination of
4 bits can represent 2^4=16 values in total and one value a given
instant. But in a combination of 4 qubits, all 16 combinations are
possible at once.
• Entanglement –
Entanglement is an extremely strong correlation that exists between
quantum particles — so strong, in fact, that two or more quantum
particles can be linked in perfect unison, even if separated by great
distances. The particles remain perfectly correlated even if separated
by great distances. Two qubits are entangled through the action of the
laser. Once they have entangled, they are in an indeterminate state. The
qubits can then be separated by any distance, they will remain linked.
When one of the qubits is manipulated, the manipulation happens
instantly to its entangled twin as well.
What can quantum computers do?
Look at point 3. This was causing a huge problem in the computing industry as
only one instruction was getting executed at any moment of time. This was a
huge waste of hardware resources as only one part of the hardware will be
running for particular instruction and of time. As problem statements were
getting heavier and bulkier, so does the amount of time in execution of those
statements. Examples of processors are Pentium 3 and Pentium 4.
Now let’s come back to our real-life problem. We could definitely say that
complexity will decrease when there are 2 queues and 2 cashiers giving tickets to
2 persons simultaneously. This is an example of Parallel Computing.
Parallel Computing :
It is the use of multiple processing elements simultaneously for solving any
problem. Problems are broken down into instructions and are solved
concurrently as each resource that has been applied to work is working at the
same time.
Advantages of Parallel Computing over Serial Computing are as follows:
1. It saves time and money as many resources working together will
reduce the time and cut potential costs.
2. It can be impractical to solve larger problems on Serial Computing.
3. It can take advantage of non-local resources when the local resources
are finite.
4. Serial Computing ‘wastes’ the potential computing power, thus Parallel
Computing makes better work of the hardware.
Types of Parallelism:
1. Bit-level parallelism –
It is the form of parallel computing which is based on the increasing
processor’s size. It reduces the number of instructions that the system
must execute in order to perform a task on large-sized data.
Example: Consider a scenario where an 8-bit processor must compute
the sum of two 16-bit integers. It must first sum up the 8 lower-order
bits, then add the 8 higher-order bits, thus requiring two instructions to
perform the operation. A 16-bit processor can perform the operation
with just one instruction.
2. Instruction-level parallelism –
A processor can only address less than one instruction for each clock
cycle phase. These instructions can be re-ordered and grouped which
are later on executed concurrently without affecting the result of the
program. This is called instruction-level parallelism.
3. Task Parallelism –
Task parallelism employs the decomposition of a task into subtasks and
then allocating each of the subtasks for execution. The processors
perform the execution of sub-tasks concurrently.
4. Data-level parallelism (DLP) –
Instructions from a single stream operate concurrently on several data – Limited
by non-regular data manipulation patterns and by memory bandwidth
Why parallel computing?
• The whole real-world runs in dynamic nature i.e. many things happen
at a certain time but at different places concurrently. This data is
extensively huge to manage.
• Real-world data needs more dynamic simulation and modeling, and for
achieving the same, parallel computing is the key.
• Parallel computing provides concurrency and saves time and money.
• Complex, large datasets, and their management can be organized only
and only using parallel computing’s approach.
• Ensures the effective utilization of the resources. The hardware is
guaranteed to be used effectively whereas in serial computation only
some part of the hardware was used and the rest rendered idle.
• Also, it is impractical to implement real-time systems using serial
computing.
Applications of Parallel Computing:
• Databases and Data mining.
• Real-time simulation of systems.
• Science and Engineering.
• Advanced graphics, augmented reality, and virtual reality.
Limitations of Parallel Computing:
• It addresses such as communication and synchronization between
multiple sub-tasks and processes which is difficult to achieve.
• The algorithms must be managed in such a way that they can be
handled in a parallel mechanism.
• The algorithms or programs must have low coupling and high cohesion.
But it’s difficult to create such programs.
• More technically skilled and expert programmers can code a
parallelism-based program well.
Future of Parallel Computing: The computational graph has undergone a great
transition from serial computing to parallel computing. Tech giant such as Intel
has already taken a step towards parallel computing by employing multicore
processors. Parallel computation will revolutionize the way computers work in
the future, for the better good. With all the world connecting to each other even
more than before, Parallel Computing does a better role in helping us stay that
way. With faster networks, distributed systems, and multi-processor computers,
it becomes even more necessary.
6, Higher Cost: If you want to use cloud services uninterruptedly then you need
to have a powerful network with higher bandwidth than ordinary internet
networks, and also if your organization is broad and large so ordinary cloud
service subscription won’t suit your organization. Otherwise, you might face
hassle in utilizing an ordinary cloud service while working on complex projects
and applications. This is a major problem before small organizations, that
restricts them from diving into cloud technology for their business.
7. Recovery of lost data in contingency: Before subscribing any cloud service
provider goes through all norms and documentations and check whether their
services match your requirements and sufficient well-maintained resource
infrastructure with proper upkeeping. Once you subscribed to the service you
almost hand over your data into the hands of a third party. If you are able to
choose proper cloud service then in the future you don’t need to worry about the
recovery of lost data in any contingency.
8. Upkeeping(management) of Cloud: Maintaining a cloud is a herculin task
because a cloud architecture contains a large resources infrastructure and other
challenges and risks as well, user satisfaction, etc. As users usually pay for how
much they have consumed the resources. So, sometimes it becomes hard to
decide how much should be charged in case the user wants scalability and extend
the services.
9. Lack of resources/skilled expertise: One of the major issues that companies
and enterprises are going through today is the lack of resources and skilled
employees. Every second organization is seeming interested or has already been
moved to cloud services. That’s why the workload in the cloud is increasing so
the cloud service hosting companies need continuous rapid advancement. Due to
these factors, organizations are having a tough time keeping up to date with the
tools. As new tools and technologies are emerging every day so more
skilled/trained employees need to grow. These challenges can only be minimized
through additional training of IT and development staff.
10. Pay-per-use service charges: Cloud computing services are on-demand
services a user can extend or compress the volume of the resource as per needs.
so you paid for how much you have consumed the resources. It is difficult to
define a certain pre-defined cost for a particular quantity of services. Such types
of ups and downs and price variations make the implementation of cloud
computing very difficult and intricate. It is not easy for a firm’s owner to study
consistent demand and fluctuations with the seasons and various events. So it is
hard to build a budget for a service that could consume several months of the
budget in a few days of heavy use.
Number of Server Cloud computing has Few Fog computing has Large number
Nodes number of server nodes. of server nodes.
Geographical
Distribution It is centralized. It is decentralized and distributed.
Dependence on the
quality of core Requires strong network Can also work in Weak network
network core. core.
Edge Computing
Computation takes place at the edge of a device’s network, which is known as
edge computing. That means a computer is connected with the network of the
device, which processes the data and sends the data to the cloud in real-time.
That computer is known as “edge computer” or “edge node”.
With this technology, data is processed and transmitted to the devices instantly.
Yet, edge nodes transmit all the data captured or generated by the device
regardless of the importance of the data.
Here Fog Computing was introduced and becomes an ideal solution.
Fog Computing
Fog computing is an extension of cloud computing. It is a layer in between the
edge and the cloud. When edge computers send huge amounts of data to the
cloud, fog nodes receive the data and analyze what’s important. Then the fog
nodes transfer the important data to the cloud to be stored and delete the
unimportant data or keep them with themselves for further analysis. In this way,
fog computing saves a lot of space in the cloud and transfers important data
quickly.
Grid Computing:
Grid Computing is a Distributed computing architecture. In grid computing,
resources are used in collaborative pattern, and also in grid computing, the users
do not pay for use.
Let’s see the difference between cloud and grid computing which are given
below:
In cloud computing, the users pay While in grid computing, the users do
5. for the use. not pay for use.
Grid Computing
• Difficulty Level : Medium
• Last Updated : 17 Jan, 2022
Grid Computing can be defined as a network of computers working together to
perform a task that would rather be difficult for a single machine. All machines
on that network work under the same protocol to act as a virtual supercomputer.
The task that they work on may include analyzing huge datasets or simulating
situations that require high computing power. Computers on the network
contribute resources like processing power and storage capacity to the network.
Grid Computing is a subset of distributed computing, where a virtual
supercomputer comprises machines on a network connected by some bus,
mostly Ethernet or sometimes the Internet. It can also be seen as a form
of Parallel Computing where instead of many CPU cores on a single machine, it
contains multiple cores spread across various locations. The concept of grid
computing isn’t new, but it is not yet perfected as there are no standard rules and
protocols established and accepted by people.
Working:
A Grid computing network mainly consists of these three types of machines
1. Control Node:
A computer, usually a server or a group of servers which administrates
the whole network and keeps the account of the resources in the
network pool.
2. Provider:
The computer contributes its resources to the network resource pool.
3. User:
The computer that uses the resources on the network.
When a computer makes a request for resources to the control node, the control
node gives the user access to the resources available on the network. When it is
not in use it should ideally contribute its resources to the network. Hence a
normal computer on the node can swing in between being a user or a provider
based on its needs. The nodes may consist of machines with similar platforms
using the same OS called homogeneous networks, else machines with different
platforms running on various different OSs called heterogeneous networks. This
is the distinguishing part of grid computing from other distributed computing
architectures.
For controlling the network and its resources a software/networking protocol is
used generally known as Middleware. This is responsible for administrating the
network and the control nodes are merely its executors. As a grid computing
system should use only unused resources of a computer, it is the job of the
control node that any provider is not overloaded with tasks.
Another job of the middleware is to authorize any process that is being executed
on the network. In a grid computing system, a provider gives permission to the
user to run anything on its computer, hence it is a huge security threat for the
network. Hence a middleware should ensure that there is no unwanted task
being executed on the network.
The meaning of the term Grid Computing has changed over the years, according
to “The Grid: Blueprint for a new computing infrastructure” by Ian Foster and
Carl Kesselman published in 1999, the idea was to consume computing power
like electricity is consumed from a power grid. This idea is similar to the current
concept of cloud computing, whereas now grid computing is viewed as a
distributed collaborative network. Currently, grid computing is being used in
various institutions to solve a lot of mathematical, analytical, and physics
problems.
Advantages of Grid Computing:
1. It is not centralized, as there are no servers required, except the control
node which is just used for controlling and not for processing.
2. Multiple heterogeneous machines i.e. machines with different
Operating Systems can use a single grid computing network.
3. Tasks can be performed parallelly across various physical locations and
the users don’t have to pay for them (with money).
Disadvantages of Grid Computing :
1. The software of the grid is still in the involution stage.
2. A super fast interconnect between computer resources is the need of
hour.
3. Licensing across many servers may make it prohibitive for some
applications.
4. Many groups are reluctant with sharing resources .
System
components are
Many operations located at
are performed different
1. simultaneously locations
Multiple
Multiple computers
processors perform
perform multiple multiple
3. operations operations
It may have
shared or It have only
distributed distributed
4. memory memory
Improves
Computer system
communicate scalability,
Processors with each other fault tolerance
communicate through Improves the and resource
with each other message system sharing
5. through bus passing. 6. performance capabilities
Soft Computing:
Soft Computing could be a computing model evolved to resolve the non-linear
issues that involve unsure, imprecise and approximate solutions of a tangle.
These sorts of issues square measure thought of as real-life issues wherever the
human-like intelligence is needed to resolve it.
Difference between AI and Soft Computing:
S.NO. A.I. SOFT COMPUTING
Branches of AI :
Branches of soft computing :
1. Reasoning
2. Perception 1. Fuzzy systems
3 3. Natural language 2. Evolutionary computation
processing 3. Artificial neural computing
S.NO. A.I. SOFT COMPUTING
AI has countless
applications in healthcare
and widely used in They are used in science and
analyzing complicated engineering disciplines such as data
4 medical data. mining, electronics, automotive, etc.
They require exact input They can deal with ambiguous and noisy
7 sample. data.
install.packages("neuralnet")
library(neuralnet)
# Load dataset
df <- iris[1:100, ]
nn = neuralnet(Species ~ Sepal.Length
png(file = "neuralNetworkGFG.png")
# Plot
plot(nn)
dev.off()
Output:
Example 2:
In this example, let us create more reliable neural network using multi-layer
neural network and make predictions based on the dataset.
Step 1: Install the required package
install.packages("neuralnet")
library(neuralnet)
df <- mtcars
png(file = "neuralNetwork2GFG.png")
# Plot
plot(nn)
dev.off()
vs = c(0, 1, 1)
cyl =c(6, 8, 8)
gear = c(4, 5, 4)
carb = c(4, 3, 3)
cat("Predicted values:\n")
print(Predict$net.result)
print(pred)
Output:
Predicted values:
[,1]
[1,] 0.3681382
[2,] 0.9909768
[3,] 0.9909768
h11 = F(r)
For all the other hidden layers repeat the same procedure. Keep repeating the
process until reach the last weight set.
• Step 1: The first step is to pick the dataset. Here in this example, let’s
work on the Boston dataset of the MASS package. This dataset typically
deals with the housing values in the fringes or suburbs of Boston. The
goal is to find the medv or median values of the houses occupied by its
owner by using all the other available continuous variables. Use
the set.seed() function to generate random numbers.
• r
set.seed(500)
library(MASS)
• Step 2: Then check for missing values or data points in the dataset.
If any, then fix the data points which are missing.
• r
• Output:
crim zn indus chas nox rm age dis rad
tax ptratio black lstat medv
0 0 0 0 0 0 0 0 0
0 0 0 0 0
• Step 3: Since no data points are missing proceed towards preparing
the data set. Now randomly split the data into two sets, Train set and
Test set. On preparing the data, try to fit the data on a linear
regression model and then test it on the test set.
• r
round(0.75 * nrow(data)))
summary(lm.fit)
• Output:
Deviance Residuals:
Min 1Q Median 3Q Max
-14.9143 -2.8607 -0.5244 1.5242 25.0004
Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) 43.469681 6.099347 7.127 5.50e-12 ***
crim -0.105439 0.057095 -1.847 0.065596 .
zn 0.044347 0.015974 2.776 0.005782 **
indus 0.024034 0.071107 0.338 0.735556
chas 2.596028 1.089369 2.383 0.017679 *
nox -22.336623 4.572254 -4.885 1.55e-06 ***
rm 3.538957 0.472374 7.492 5.15e-13 ***
age 0.016976 0.015088 1.125 0.261291
dis -1.570970 0.235280 -6.677 9.07e-11 ***
rad 0.400502 0.085475 4.686 3.94e-06 ***
tax -0.015165 0.004599 -3.297 0.001072 **
ptratio -1.147046 0.155702 -7.367 1.17e-12 ***
black 0.010338 0.003077 3.360 0.000862 ***
lstat -0.524957 0.056899 -9.226 < 2e-16 ***
---
Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
center = mins,
library(neuralnet)
n <- names(train_)
nn <- neuralnet(f,
data = train_,
linear.output = T)
Now our model is fitted to the Multi-Layered Neural network. Now combine all
the steps and also plot the neural network to visualize the output. Use
the plot() function to do so.
• r
# R program to illustrate
set.seed(500)
# Import required library
library(MASS)
round(0.75 * nrow(data)))
summary(lm.fit)
center = mins,
library(neuralnet)
n <- names(train_)
linear.output = T)
plot(nn)
Output:
Numpy Gradient – Descent Optimizer
of Neural Networks
• Difficulty Level : Hard
• Last Updated : 18 Oct, 2021
In differential calculus, the derivative of a function tells us how much the output
changes with a small nudge in the input variable. This idea can be extended to
multivariable functions as well. This article shows the implementation of the
Gradient Descent Algorithm using NumPy. The idea is very simple- start with an
arbitrary starting point and move towards the minimum (that is -ve of gradient
value), and return a point that is as close to the minimum.
GD() is a user-defined function employed for this purpose. It takes the following
parameters:
• gradient is a function which or it can be a python callable object which
takes a vector & returns the gradient of a function which we are trying
to minimize.
• start is the arbitrary starting point which we give to the function, it is a
single independent variable. It can also be a list, Numpy array for
multivariable.
• learn_rate controls the magnitude by which the vectors get updated.
• n_iter is the number of iterations the operation should run.
• tol is the tolerance level that specifies the minimum movement in each
iteration.
Given below is the implementation to produce out required functionality.
Example:
• Python3
import numpy as np
res = start
for _ in range(n_iter):
# function.
break
res += new_val
# we return a vector as the gradient can be
return res
# Example 1
# Example 2
Output:
The vector notation of global minima:[9.5 9.25 8.75 8.25 7.75 7.5 ]
The vector notation of global minima: [2.0539126e-15 2.0539126e-15]
Lets see relevant concepts used in this function in detail.
Tolerance Level Application
The below line of code enables GD() to terminate early and return before n_iter is
completed if the update is less than or equal to tolerance level this particularly
speeds up the process when we reach a local minimum or a saddle point where
the increment movement is very slow due to very low gradient thus it speeds up
the convergence rate.
• Python3
if np.all(np.abs(new_val) <= tol):
break
import numpy as np
res = start
for _ in range(n_iter):
break
res += new_val
return res
Output:
[9.9 9.9]
The value returned by the algorithm is not even close to 0. This indicates that our
algorithm returns before converging to global minima
One-to-One RNN
The above diagram represents the structure of the Vanilla Neural Network. It
is used to solve general machine learning problems that have only one input and
output.
Example: classification of images.
2. One-to-Many RNN:
One-to-Many RNN
This RNN creates a single output from the given series of inputs.
Example: Sentiment analysis is one of the examples of this type of network, in which
a text is identified as expressing positive or negative feelings.
4. Many-to-Many RNN:
Many-to-Many RNN
• W = W - α V⁄√S + ε
Kingma and Ba, the proposers of Adam, recommended the following
values for the hyperparameters.
α = 0.001
β1 = 0.9
β2 = 0.999
ε = 10-8
The choice of correct learning rate is very important as it ensures that Gradient
Descent converges in a reasonable time. :
For linear regression Cost, the Function graph is always convex shaped.
• Python3
import numpy as np
class Linear_Regression:
self.X = X
self.Y = Y
self.b = [0, 0]
Y_pred = self.predict()
Y = self.Y
m = len(Y)
np.sum(Y_pred - Y)))
np.sum((Y_pred - Y) * self.X)))
Y_pred = np.array([])
if not X: X = self.X
b = self.b
for x in X:
return Y_pred
p, e = Y_pred, self.Y
n = len(Y_pred)
return 1-sum(
[
abs(p[i]-e[i])/e[i]
for i in range(n)
if e[i] != 0]
)/n
m = len(self.Y)
return J
f = plt.figure(fig)
f.show()
def main():
iterations = 0
steps = 100
learning_rate = 0.01
costs = []
Y_pred = regressor.predict()
while 1:
Y_pred = regressor.predict()
cost = regressor.compute_cost(Y_pred)
costs.append(cost)
regressor.update_coeffs(learning_rate)
iterations += 1
if iterations % steps == 0:
print(iterations, "epochs elapsed")
regressor.get_current_accuracy(Y_pred))
if stop == "y":
break
h = plt.figure('Verification')
h.show()
if __name__ == '__main__':
main()
Output:
Given is a Work vs Experience dataset of a company and the task is to predict the
salary of a employee based on his / her work experience.
This article aims to explain how in reality Linear regression mathematically
works when we use a pre-defined function to perform prediction task.
Let us explore how the stuff works when Linear Regression algorithm gets
trained.
Iteration 1 – In the start, θ0 and θ1 values are randomly chosen. Let us suppose,
θ0 = 0 and θ1 = 0.
• Predicted values after iteration 1 with Linear regression
hypothesis.
• Cost Function – Error
Now, similar to iteration no. 1 performed above we will again calculate Cost
function and update θj values using Gradient Descent.
We will keep on iterating until Cost function doesn’t reduce further. At that point,
model achieves best θ values. Using these θ values in the model hypothesis will
give the best prediction results.
Serverless Computing and FaaS Model - The Next Stage in Cloud Computing
29, Sep 20