HOME
PRIVACY POLICY
ABOUT US

DEEP LEARNING SPECIFIC PYTHON UNDERSTANDING PART 2 (CLASSES, MODULE AND PIP MANAGER )

python for deep learning part 2 | DEEP LEARNING ( AI ) FOR BEGINNERS AND CODERS | MULTIPLEWORDS BY PROGRAMMERS

Python is an awesome programming language for beginners in programming itself and its really make life easy in writing deep learning models. In previous post we have discussed variable operators, loops, function, lambda function if you don't know any of this you can go read here that post. In this post we will discuss about class module, pip manager and syntax which are very less in python. After reading this you will be able to make simple python program easily.

SYNTAX IN PYTHON

Syntax means it is the rules in which you have abide to write program or description of all special character which we use to distinguished between two entities in the program . Let say you are writing a conditional operator (if) statement so you tell compiler that where if statement is started from which statement you have to run program to which statement it has to stop. For declaring start and end of If statement we have to use special symbol like in C we use '{' to start , and '}' to end If statement likewise different language have different symbols. In python we don't have that symbol we only use Space and number of empty lines to distinguish. It is also called as indentation

In python for ( IF, FOR, WHILE) loop. We use '.' to start loop and each statement in the operator and the loop should have same starting spaces and should be end with four empty lines. Example is given below.

As you can seen in the above example each print statement has same beginning space and each if and while is separated by empty lines in between them like some syntax is used for function, lambda function classes.

CLASSES

In starting python was designed as sequential language but afterwards due to impact of object oriented programming python was added with object oriented capabilities to use object oriented approach. We can define classes . And we can divide full program into different classes and each classes interact with other to give us required result. Each class consist of two things one is property and one is function. you can define as many properties and function you want to declare in CLASSES. Let say you to create and use Dog object which can show his color and has one function as it can make sound. Since color can be declared as property and make sound as function. In python you have first declare class and then you have create object to use in the program

Here above have defined one dog class in python constructor in created by __init__ . Constructor means when dog object is created than this function is called by default. You can provide color of dog when dog is initialized in program.


In above two line we have initialised our dog object with color as white and called make sound function in it. Likewise you can create as many classes in python with as any properties and function you like is object orientation approach makes programming easy and let say make our mind to visualize different part of program as object. Our mind can easily remember object which is same as real world object than just symbols. It also helps in making programming decision properly because you can visualize something which makes your mind to comprehend and take decisions.

Super classes are classes which is derived from some classes. In concept is mainly used to reduce redundant code which means some code cannot be repeated multiple times. In super classes you derive that class from some other class due to which all those functions and properties are there in previous class you can access in this class object and even you can override previous class function in the derived class function. Let say you have animal class which has two properties as color and makesound function and now you will derived new dog and cat classes from animal class, due to which its color and function will be inherited in dog and cat class

You can see in the above example we have derived dog and cat classes from animal classes and also override makesound function in both classes due to which whenever you call makesound of derived class like dog or cat it will output dog and cat class and one thing to noticed where that we have used super.__init__() which actually call's animal constructor to assign color in animal class

Just run above code in google colab to see its results, You will find cat makesound meaw and dog sound as bark.

PIP MANAGER

pip manager is library download manager use by python to download external third party library to use in your program to make your life easy and use other code to help you in some task Python is wide ecosystem to carry out any operation as your needed. All deep learning libraries are written and published on pip so that any body can use it. Many libraries such as numpy, pandas you got as free here. You first need to type pip install library_name to install library locally to use it in your project

CONCLUSION

In this post we have learned about basic python function which are needed to train and practise deep learning. You only need basic python to make deep learning models, We have explores classes, super classes, syntax and pip manager in python.

taher AI Professional

Related Posts