Posts

Showing posts from May, 2020

NumPy Crash Course: Array Basics

Lists vs. Arrays We’re all familiar with the standard Python list — a mutable object that has great flexibility in that not all elements of the list need to be of a homogeneous data type. That is, you can have a list containing integers, strings, floats, and even other objects. my_list = [2, {'dog': ['Rex', 3]}, 'John', 3.14] The above is a perfectly valid list containing multiple data types as elements — even a dictionary which contains another list! However, to support all these simultaneous data types, each Python list element must contain its own unique information. Each element acts as a pointer to a unique Python Object. Because of this inefficiency, it becomes much more taxing to use lists as they grow larger and larger. >>>for element in my_list: print(type(element)) <class 'int'> <class 'dict'> <class 'str'> <class 'float'> With an array, we do away with the flexibility o

PyTorch : A Deep Learning Framework

Image
Part 1 — What are Tensors and Gradients? PyTorch is a open source, deep learning framework developed by Facebook. INSTALLATION OF PYTORCH The installation of PyTorch Package is done either through pip manager or conda command. I would recommend using Google Colab as our IDE . PyTorch can be used by directly importing torch package import torch # importing pytorch library in Google Colab # pip install torch===1.5.0 torchvision===0.6.0 -f https://download.pytorch.org/whl/torch_stable.html # Through pip installation # !conda install pytorch cpuonly -c pytorch -y # Through Conda Installation WHAT IS A TENSOR? The main element of PyTorch is PyTorch Tensor. Tensor is a type of data structure in Linear Algebra represented in the form of multi-dimensional array. It can be a scalar, vector , matrix or any n dimension array. Whenever a library is imported in Python it is treated as an object. Object has 2 important features. Methods Attributes