Phone

+919997782184

Email

support@roboticswithpython.com

Geeks of Coding

Join us on Telegram

Viewing 0 reply threads
  • Author
    Posts
    • #1192
      Yash AroraYash Arora
      Keymaster

      Question 1 –
      What is wrong with the following class:

      class toy_set(Dataset):
          
          # Constructor with defult values 
          def __init__(self, length = 100, transform = None):
              self.len = length
              self.x = 2 * torch.ones(length, 2)
              self.y = torch.ones(length, 1)
              self.transform = transform
           
          # Getter
          def __getitem__(self, index):
              sample = self.x[index], self.y[index]
              if self.transform:
                  sample = self.transform(sample)     
              return sample
          
          # Get Length
          def __len__(self):

      Answer :
      the method __len__(self) does not return anything

      Question 2 –
      Which of the following are the build-in functions you need to define while customizing the class for transforming?

      Answer :

      __call__
      __init__
Viewing 0 reply threads
  • You must be logged in to reply to this topic.