Course Hero Logo

vertopal.com L 14 PyTorch Datasets.pdf - ECE 329 Lecture 14...

Course Hero uses AI to attempt to automatically extract content from documents to surface to you and others so you can study better, e.g., in search results, to enrich docs, and more. This preview shows page 1 - 3 out of 7 pages.

ECE 329 Lecture 14 PyTorch DatasetsObject and Class in Phyton:Class:Class is a set or category of things having some property or attribute incommon and differentiated from others by kind, type, or quality.Object:object is one of instances of the class. which can perform the functionalitieswhich are defined in the class.self:self represents the instance of the class. By using theselfkeyword we canaccess theattributesandmethodsof the class in python.init:"init" is a reseved method in python classes. It is known as a constructor inobject oriented concepts. This method called when an object is created from theclass and it allow the class to initialize the attributes of a class.Object and Class in PhytonclassRobot:def__init__(self, name, color, weight):self.name=nameself.color=colorself.weight=weightdefintroduce_self(self):print("My name is "+self.name)# this in Java# r1 = Robot()# r1.name = "Tom"# r1.color = "red"# r1.weight = 30# r2 = Robot()# r2.name = "Jerry"# r2.color = "blue"# r2.weight = 40r1=Robot("Tom","red",30)r2=Robot("Jerry","blue",40)r1.introduce_self()r2.introduce_self()DatasetsIf you are working on a real-time project involving Deep Learning, it's common thatmost of your time goes into handling data, rather than the neural network that youwould build. This is because data is like fuel for your network: the more appropriateit is, the faster and the more accurate the results are! One of the main reasons foryour neural network to underperform might be due to bad, or poorly understood
data. Hence it is important to understand, preprocess, and load your data into thenetwork in a more intuitive way.Code for processing data samples can get messy and hard to maintain; we ideallywant our dataset code to be decoupled from our model training code for betterreadability and modularity.PyTorch provides two data primitives: (1)torch.utils.data.DataLoaderand (2)torch.utils.data.Datasetthat allow you to use pre-loaded datasets as well as yourown data.Datasetstores the samples and their corresponding labels. You will need aDataLoader (next lecture)wraps an iterable around the Dataset to enable easyaccess to the samplesPyTorch domain libraries provide a number of pre-loaded datasets, all of which arepre-loaded in theclass torch.datasets.

Upload your study docs or become a

Course Hero member to access this document

Upload your study docs or become a

Course Hero member to access this document

End of preview. Want to read all 7 pages?

Upload your study docs or become a

Course Hero member to access this document

Term
Fall
Professor
Zilles

Newly uploaded documents

Show More

Newly uploaded documents

Show More

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture