Monday, February 19, 2018

Beginner's guide to Artificial Intelligence

We've seen a lot of hype when it comes to AI. We also know about Sophie - The first robot to become a citizen. Some people have shown concerns about AI being dangerous and some are very excited about the seamless possibilities it brings with it.
Along with this excitement, there are way too many questions also. The amount of information we get when we google AI is overwhelming. So, in today's post, I intend to answer some of those questions and give useful links to readers for them to get started.

Now, there are 3 most important things one needs to remember, to understand AI.
  1. Lots of data is required.
  2. Artificial Neural Networks are the way to go.
  3. Training will take a lot of time.
The basic concept of AI is that it "learns" on its own using examples and you don't need to "hard wire" it to do something specific when a task is given. 

Let's take an example:
This is for EC students to understand AI -  
If you have to code a simple logic gate like NAND, what you would do is write down its truth table and then create the respective variables and then assign them using a nested if-else or a switch case and your work is done! 
Suppose you try bringing in AI here, the scenario changes -
  • Here, you can create a model, and train it by "teaching" what NAND gate does. 
  • Later, the model can be trained to get outputs for other logic gates as well, by making it learn by example. 
  • When it is training, it'll give ridiculous outputs and get "rewarded" or "punished" accordingly. (Covered later in the post)
  • Based on how it is rewarded, it improves its own outputs and predicts accurately over time.

So the next time you said, 'what is the output of A OR B?', it'll still be able to generate it accurately even when you thought you created a model for the NAND gate. Really, you made a general logic gates model and the AI learnt by example on how to give the output for that OR gate!
Now, you might think that all of this sounds great, but how do I actually implement it?
By using Artificial Neural Networks!

Now let me introduce you to ANNs:
Credits:Medium

The concept of ANNs comes from a mathematical object, 'Perceptron'. If I combine multiple such math elements together, in some order, I get a neural network! (I won't be jumping into the math of ANN as I have saved that for another post)
Generally, a neural network consists of these perceptrons in an input layer, one or many hidden layers and an output layer.
If I go back to the logic gates example, then since I have 2 inputs, I'll have 2 perceptrons in my input layer. Since there are 4 combinations, I'll have 4 perceptrons in my hidden layer. Since I get a single output, I'll have just one perceptron in my output layer. Within the hidden layer is where 'magic' happens.
Credits: http://ataspinar.com/2016/12/22/the-perceptron/
Basically, a perceptron always has two inputs. One of them is the normal input and the other one is weight. This weight input is the one that can be changed to vary the perceptron's output. The weight is the reason ANNs can 'learn'. 
Basically, learning involves changing these weights according to some criteria so that the output of the perceptron changes. This criteria is decided by "rewards" and "punishments".

Suppose I'm teaching my perceptron and I know the output should be 1. Initially the weights will be at random. Suppose the perceptron does give me a 1, then I 'reward' it. 
Rewarding means increasing the weight so that the output remains what it was (in this case, 1).
Suppose I get a 0 then I 'punish' it. 
Punishing means decreasing the weight so I don't get the output that I got now (in this case, 0).
Now the question arises, how to reward or punish the network?
Here comes the 'loss function' which is nothing but the difference between the output and input, which has to be minimized.
So how do I minimize this loss function?
The simplest way to do that is through 'gradient descent', which means that you minimize this loss in small steps, till you get a zero loss. My next post will contain more detail on this.

So the story so far is that the network learns using 3 things - changing weights, evaluating the loss function and by minimizing loss(gradient descent).
You can use ANNs here to distinguish several images. There are images available online that are called 'Datasets' which can be used to make your network learn. 

Now that you know how the network learns, it's time to dive in  & learn how this will help in a real time application. 

Let's take a look at the generalized steps:
  • First, you consider any algorithm of your choice and run these datasets along with known output, through your network.
  • The network 'trains' itself from the data you just gave it. This step takes a lot of time.
  • At the end of the training, the network would have adjusted its weights and other parameters(called hyper parameters) to get the right output on this large dataset.
  • Now, you test it - You send one image in and see the efficiency of your network. If it's perfect, yay! If it isn't, then you change the algorithm and try again.
  • After you've got your optimized algorithm & trained your network, you can generate a json or xml file of the trained network's hyper parameters and then deploy them wherever you like and it'll work like magic!

So, this is how ANNs can be used to do things without explicitly coding them. This is the first step towards a generalized AI, where a lot more goes in.

These steps are actually of a learning process called 'supervised learning' where you know the real world output and you're just training the network to tell you that. There are 2 other learning formats - semi supervised learning and unsupervised learning. I'll cover these two in a later post.

That's it for today's post. Stick around to know the math behind all this, which will be the topic for my next post. I'll also put up useful links there and several helpful videos.



Tuesday, September 5, 2017

REST - Representational State Transfer

Today's post is a little different. I read a little about the REST architecture and found it fascinating. I hope you do too, after reading this. 
REST is an architectural style that makes up the web. 
HTTP is mainly a pointer that can track any resource in the world. It has versatility, but till today we use it only for browsing web pages. In fact, we can’t really think of any other uses of it. But it was built to have far more applications than its given credit for. Basically, HTTP, rather the entire web today focuses its application on human interaction with the machine; what we fail to learn is that HTTPs are much more flexible than that, i.e. applications can be made using HTTP for machine interaction as well. The webpage as we know it is mainly a representation of several relevant resources put together (like an image, videos). This is understandable by humans, not by computers. So, computers really don’t know what useful information they have brought to you. All they do is go get it for you. Imagine machines doing stuff like that for each other and generating very useful info smartly without human interaction. HTTP is capable of creating another representation (like the webpage) that is understandable by the computer too. Sort of like a binary representation of the data that you’re fetching. That way, the system too understands what data is given, and can communicate to other systems using the data and its binary representation. This kind of access, when given to a machine, can provide great results if a smartness is programmed in machines to learn the information they just fetched and try to understand the priority &/or requirement of the human accessing request and get far better results than what exists.
Credits: www.ibm.com
Let me try and give an example : Suppose you want a cheap gadget, say a smartphone. Now, you talk to the people you know and among them, none have the phone available for that budget. But, a well-wisher recommends you to some other person who he thinks will have the phone available for your budget. Now, machines can't do that because they have no idea what resources they've picked up from world wide web, since they're not in machine understandable formats, but human understandable formats. But, it'd be excellent if machines had such intelligence. Say machine X is requesting some resource from a server, say, machine Y. Now, machine Y has no such resources but given that it collects such immense data (assume it can understand it), then Y can definitely be given intelligence to tell machine X that it doesn't have the resource available but X's request maybe processed by some other server, machine Z. This will definitely enable machines to have human-like intelligence and that can get work done a lot faster and more efficiently.

For more info you can check out the wiki page : 
https://en.wikipedia.org/wiki/Representational_state_transfer

Wednesday, August 30, 2017

Finally Understanding VLSI - The Four Categories

Today's post is a continuation of the previous post, "About the N-MOSFET" which was about the simple N-MOSFET. If you haven't already checked it out, I highly recommend that you do.

This post is the "First thing's first" type of post so let's start with the 4 basic categories or levels of abstraction into which the vast VLSI field maybe divided.
1.Physical level/Transistor level.
2.Circuits level.
3.Sub-systems level/ Architectural level.
4.Systems level.

In the first category, one learns about all the physical properties of a MOSFET, like what should the physical parameters be, in order to change its electrical parameters. Alongside, (s)he also learns the 4 basic terminals of a MOSFET - Source, Gate, Drain and Bulk. Generally, the bulk terminal isn't considered in initial stages of learning designing concepts. But it comes into picture when one designs advanced circuits.  Knowledge of this is a must, and frankly it's a little complex and boring to understand, but it's not a lengthy concept. I'll write another post just on this topic later.

In the Circuits level one first learns how to create the basic gates and then put them together to make simple circuits which can perform simple functions. I'll write about the basic gates (NOT, AND & OR) in the upcoming post. This can be considered analogous to functions in programming, where small functions with minor problem definitions can be created so they can be put together to create a solution for the major problem definition. In this level, one also learns how to design layouts for the circuit developed, using the standard rules of layout design, which is a vast field. Examples for this level maybe CMOS subcircuits, and CMOS amplifiers.

Architecture level deals with the sub-major problem-definition solutions. Here, the circuits developed in the previous levels are put together to make a valid architecture for the sub-solution. Examples maybe CMOS Op-Amp, High level amplifiers, comparators etc. These are put together in the next level in form of a block diagram to create working systems.

The Systems level is similar to designing a block diagram where each block represents the sub-system circuitry. The designer of this level need not know what happens at the electrons level in the transistor. (S)he is just concerned in placing all blocks together so that they work efficiently &/or economically as one whole system. The examples in this level maybe industrially available Analog to Digital converters (ADCs) or Digital to Analog Converters (DACs).

After learning all the four concepts, one has to decide which field interests him/her the most and go ahead in that field. Generally, people recommend that one gains exposure in all of the fields for complete growth in knowledge of VLSI. Also, people usually get started with the verification of developed systems and go on towards R&D in either of the four categories.

I'll come up with another post which can elaborate on real time examples of these 4 levels so the reader finds it easy to understand and gets motivated to learn theory regarding it. Of course, the post will come up after I have elaborately explained the above levels of abstraction.


Tuesday, July 18, 2017

Finally Understanding VLSI : About the MOSFET

Today’s post is about the basics of VLSI. VLSI is the acronym of Very Large Scale Integration. In a VLSI chip, the number of transistors that are integrated ranges from 20,000-100,000. The type of transistors used is varied based on application. In this post and a couple of following posts, I will be writing about NMOS transistors and extending it to CMOS. Today, GaAs transistors are being used as they also have lower power consumption and are fast at the same time. Also, their design is on similar lines as that of NMOS. So basically, once you’re thorough with design of NMOS, everything else is pretty much just an extension.

Understanding the working of a MOS transistor is very important to understand VLSI, so I will begin with MOS. MOS is short for Metal Oxide Semiconductor. As the name suggests, these transistors are, in general sense a combination of metal and silicon oxide. (Today, polysilicon is used instead of the metal, but the name still remains MOS) Most importantly, these are Field Effect Transistors (FETs), which means, they work based on the variations of the voltage supplied to them and not on the variations of current supplied to them. This difference has to be understood because that’s what differentiates BJTs (which are now obsolete) and FETs.  

Basically any FET contains three terminals, Drain, Gate and Source(4th also exists, called the bulk terminal. To put it simply though, 3 terminals maybe studied). The output current is produced between source and drain, with the voltage supplied to the gate. (This sentence may be hard to follow for laymen, but just go with me on this one; explanation is on its way) When I say output flows between source & drain, it means that there’s a path for it flow and that path is called the “channel”. 

Based on whether the channel is present or absent when the transistor is idle, a MOS transistor is classified as:
1. Depletion-MOS (DMOS): Where the channel is present when the MOS is idle.
2. Enhancement-MOS (EMOS): Where the channel is absent when the MOS is idle. 

These classifications basically give an idea if the transistor is ON or OFF, when idle (i.e. when there is no voltage input on the gate terminal). So, since a channel exists on the DMOS, this transistor is ON even when there is no voltage at the gate. And the EMOS is OFF, when there is no voltage supplied at the gate. Each of them has separate applications.

The first image is the basic MOS symbol and the second one is cross sectional view of an n-channel MOSFET. Commonly, the EMOSFET is used in the construction of CMOS.

credits: www.elprocus.com
The Depletion MOSFET:
This transistor conducts even when gate-source voltage is zero (i.e. Vgs = 0). Consider a positive voltage across drain-source (i.e. Vds =0). Then, positive voltage at the drain attracts electrons in the channel. This motion of electrons cause the drain current Ids. Hence, the depletion MOSFET conducts at zero gate-source voltage. 
Generally, there is a particular threshold gate-source voltage above which only, a MOSFET begins to conduct. In case of n channel DMOS this voltage is negative (because the transistor conducts even at zero gate-source voltage).  
The Enhancement MOSFET:
I will explain this in detail. Here, we need an above-zero threshold voltage for the transistor to conduct (because the channel needs to be established, it is not present by default like in DMOS). 

There are three cases in the working of these devices:

1. Vgs>Vt but Vds=0 (Cutoff region): Here, the voltage at the gate is positive with respect to the source. So, the holes (substrate is p-type) start to repel from the region right below the gate. This means that the particular region is depleted of holes. Now if the Vgs is sufficiently large, it starts to attract electrons towards the region which is now depleted of holes. This establishes the n-channel (which is also called inversion region) and the depletion region is pushed below that region.

2. Vgs > Vt and Vds=0 but Vg>Vd (Linear region): The channel is established and now, electrons begin to flow from source to drain due to positive Vds. At the source end, Vg is the controlling voltage, but at the drain end, Vg-Vd is the controlling voltage. This particular condition is called the linear condition where, the current is dependent on both Vgs and Vds. The channel is resistive. 

3. Vgs > Vt but Vg<Vd (Saturation Region): In this case, the effective voltage at drain becomes less than the threshold voltage required for the channel to be established and that’s why the channel is pinched off before it reaches the drain. Now, the channel becomes highly resistive; but since the drain voltage is high, it still attracts the electrons. So the electrons continue to conduct (from drift mechanism) and they jump to the depletion region and get accelerated towards the drain. This particular condition is called saturation condition. So, now the channel current is almost fully independent of the drain voltage and is dependent only on the Vgs. So the transistor in this condition can act as a stable current source.

In the first condition we see the important difference between a BJT and FET. i.e. in the pn junction of BJT, electrons are introduced because of donor atoms, but in FET, electrons are introduced due to the gate voltage. Hence, an FET acts as a voltage controlled device; controlling voltage is the gate-source voltage.

I have written only about the n-channel MOSFET, but the p-channel MOSFET is its dual. Hence, to conduct, a p-channel MOS needs negative gate-source voltage. Every other mechanism remains the same. Also, mobility of holes is lower than that of electrons. 

Here are some links to further explanation and videos: 


Friday, October 21, 2016

EC Engineering

credits: greedge.com

Today's post is for EC engineering students or those aspiring to take up EC engineering. In this post I'll be writing about the most important subjects you should focus on in the first 2 years of engineering if you want to really grab on to concepts and are passionate about giving something to technology. I learnt this the hard way, so decided to pass this on for anybody interested in conceptual learning. If you are serious on EC engineering, then learn in depth on these subjects:

These are important subjects for the first year:

1. Basic Electronics: This subject is like an intro to EC. Almost all the topics here will be studied in your engineering course. So, this subject is like chapter one of engineering. Spend good amount of time on this subject and if possible, go just a little further than the syllabus but keep it easy on your mind because deeper topics are on their way.

2. Basic Electrical Engineering: Again, this subject also important to set roots on EC engineering. This subject is worth your time, but make sure it  doesn't go too heavy on the mind as its focus is on providing basics of working of electrical devices(like a transformer). It's more like branch out from EC, but the branch is still pretty close to the main road (If you can understand that analogy) In short, for core EC, this subject CAN’T be ignored, but it need not be taken too seriously either.

These are important subjects for the second year:

1. Analog Electronic Circuits: This subject is extremely important. Make sure you spend most of your time learning it, because it explains the working of the most basic components like diodes and transistors at the electrons level. In later stages of your education and career, if you are able to innovate or have breakthrough theories, you'd owe it all to this subject. Read further on this subject apart from your syllabus as well. Its totally worth your time.

2. Fields and Waves: This subject is also quite important if you're interested in learning deeply about communication. It has basics of electric and magnetic fields which have to be studied if you're interested to innovate in the field. You'll learn motion of electrons in different fields and what governs their speed etc., so focus on this subject as well, it's very interesting.

3. Logic Design: This subject is super important and very interesting. The best part, it's actually simple. Major subjects later on, have their basics in this subject. Focus on this subject because, if you plan on taking up masters after engineering, then GRE,GATE etc will test your knowledge of logic design. So in all the four years, keep in touch with this subject and try to update yourself through journals and other info on the net.

4. Signals and Systems: This subject sets the foundation for type of signals (discrete and analog) and their mathematical analysis. Mainly it's like the 1st unit to digital signal processing, so spend enough time for it. This subject may be difficult only for those who have a weak memory and/or dislike math. :D But of course, for those who have been questioning as to WHY math is taught, this subject practically applies math and you can actually see the signal being generated in the lab. So basically, it’s all applied math which is fun for some people, but if you hate math, I know you'll curse this subject. :D

5. Electronic Instrumentation: This subject is relatively easy, read it as a story book or something :D You will enjoy the subject as its pretty simple. Later on you can come back to books on this subject for a quick revision of topics you require to recall. Nothing more on this, just spend time on it when you feel your brain is too filled up for anything mind-taxing.

Just realized that I almost listed all the subjects in your 3rd sem. :D
But, these are important so it’s crucial that you focus on your second year, and get all concepts straight and make sure you ask your doubts (even if you think they may be really silly, don't bother about it. Just ask.)

6. Microcontrollers and microprocessors: This subject is a little tough for those who don't have a computer science background. Assembly language will require your time to understand it thoroughly, but this subject is excellent. By learning this subject, you'll learn how exactly you should proceed with applications of controllers and processors. You can make various applications using these chips easily, if you have complete knowledge of assembly language. To sum up, this subject is really important to learn so you can get habitual to programming chips and making different applications (which is what you'll probably be doing in your career unless you go for VLSI or chip design in general)

7. HDL fundamentals: This subject is awesome! For those who have a knack for programming, this subject is going to be piece of cake, really. This subject is like a state of the art subject (as in, this and microcontrollers and processors subjects are more recent than all other subjects which even our previous generation have probably studied :P ) Basically its designing a chip, by coding either its specifications or its way of functioning, or both. It’s a great subject and its fun. Your 4th sem is more fun-while-learning whereas your 3rd sem will be slightly boring as you'll have to use your mind a lot. Here, you can have fun at the same time. Even HDL lab is going to be fun as you'll see that your code works on the FPGA kit, and/or you can also simulate the chip and see its working.

8. Linear Integrated Circuits: I had a hard time getting used to this one. The first three chapters are all that need your time. Once you get them clear in your head, the rest of it is cake walk. Mainly you need to know how the IC-741 works, in its most basic level.
 The 3 important chapters are 
   1. Introduction (Don’t skip it)
   2. Op Amp parameters, performance - You might take long to understand this chapter because it’s a little complex, but it deals with in-depth learning of the op-amp.
   3. Op Amp as DC amplifiers - In this chapter, you need to know three circuits really well - non inverting amplifier, inverting amplifier and summing amplifier. 
This is a more-work, less-play type of subject; spend your time on it.

The rest of the subjects are also important and they can be handled. (See how I didn’t put math as one of the important subjects? It’s because, practically, you will be using tools and software which are developed by applying these and deeper math concepts; so unless you want to improve working algorithms or something even further, math is just for passing your exams)
Why I stressed on these above subjects is because they're more practical oriented. In your EC career, you will need in-depth knowledge of these subjects, because even if you are required some knowledge from the other subjects, you can always revise a couple of chapters. But these subjects are ones that'll make you an EC engineer. 
In your third and fourth year, knowledge of these subjects will be extremely useful. You'll first learn the technologies prevailing today, and if your basics are right, you'll start getting ideas on how to innovate in these technologies, how to go ahead with practical projects. You can read online magazines, journals and create your own DIY projects and if you have new theories, you can get guided and publish your papers. This stuff is your main work in the last 2 years of your engineering. 
Finally, to sum up everything - EC engineering goes like this- the first and second year are for you to completely understand all the theory and in the third and the final year, you'll spend time in practical application of that theory. So learn with full dedication in your first 2 years, apply them creatively in your last 2 years.
I hope this post is of some help to those who are aspiring to take up EC engineering and want a basic idea of engineering.
To those who’re in their first and second year right now, please take this seriously, it’ll be very helpful if you follow it.


Saturday, September 17, 2016

The Five Hundred meter Aperture Telescope (FAST) or The world's largest radio telescope!

The Five Hundred Meter Aperture Telescope (FAST)!
五百米口径球面射电望远镜. Yes, you read it right. China has completed the construction of the largest radio telescope built so far, and has entered a new level in the quest for searching alien life. It’s not functional yet, it will be, this month.  It is built so that weak gravitational waves can be received and we can get more knowledge on what’s out there. It can “see” 5 to 10 times farther in space better than any equipment we have right now. So, if there is an alien civilization and it is sending out signals we will be able to receive them now. The telescope will be made available to worldwide researchers after 2-3 years from now. Let’s hope we get info on alien life and also that it won’t be kept hidden to us!

Monday, June 27, 2016

Cascading Style Sheets - 3: Colors

Today’s post is short, I will be discussing about colors.

Colors make your webpage look brighter and catch the viewer’s eyes easily. Colors are always expressed in terms of RGB i.e. Red Green Blue.

There are 3 ways to specify a particular color in terms of RGB:

·       A valid name is the easiest option – like “blue” or “red” but that stuff is for basic colors and is quite okay if that is what is required by you.

·       The next way to specify the color is by specifying the detail of the amount of intensity of red, green and blue. Let me give an example and I’ll then explain in detail

Ex: rgb(255,0,0) This code, specifies red color. Intensity of each color is determined from the number specified. Range of the numbers is between 0 and 255 with 255 being the highest intensity number.

Ex2: rgb(100,0,100) This code equally divide intensity of red and blue and has no intensity of green. Now, a combination of red and blue gives purple. Hence, this code specifies purple color.

So depending on numbers, intensity of any of the three main colors can be varied and a new color can be specified.

·       This way is a little complex (in a way) because it involves specifying rgb intensity in terms of hexadecimal numbers. Again, I’ll give an example and then explain in detail.

Ex: #ff0000 This code specifies red color. Every color code contains 6 digits. First 2 digits specify intensity of red; the next two specify intensity of green and the last two specify intensity of blue. In hexadecimal, the decimal number 255 is represented by ‘ff’.

Conversion of numbers from decimal to Hex goes like this:

Decimal

Hexadecimal

0-9

0-9

10

A

11

B

12

C

13

D

14

E

15

F

16-25

10-19

26-32

1A-1F

 

This table continues till the last number 255 or in hexadecimal, FF.

This method of specifying intensity is widely used, as it is otherwise simple once we know hex numbers and the code also looks compact.

Hence, I conclude this post on colors and the 3 ways to specify them.