Hello Everyone!
I am rather new to PyTorch and I am trying to implement a previous project I had in TF in pytorch.
While testing my code so far I get the following error message:
Traceback (most recent call last):
  File "data2test.py", line 122, in <module>
    train(epoch)
  File "data2test.py", line 82, in train
    for batch_idx, (data, target) in enumerate(train_set,0):
  File "/anaconda3/lib/python3.6/site-packages/torch/utils/data/dataloader.py", line 259, in __next__
    batch = self.collate_fn([self.dataset[i] for i in indices])
  File "/anaconda3/lib/python3.6/site-packages/torch/utils/data/dataloader.py", line 135, in default_collate
    return [default_collate(samples) for samples in transposed]
  File "/anaconda3/lib/python3.6/site-packages/torch/utils/data/dataloader.py", line 135, in <listcomp>
    return [default_collate(samples) for samples in transposed]
  File "/anaconda3/lib/python3.6/site-packages/torch/utils/data/dataloader.py", line 119, in default_collate
    raise TypeError(error_msg.format(elem.dtype))
TypeError: batch must contain tensors, numbers, dicts or lists; found object

This error comes when the following function I defined for training is called:
train_set = DataLoader(dataset=molecules,
                       batch_size=args.train_batch,
                       sampler=SubsetRandomSampler(train_indices)
                       )


def train(epoch):

    model.train()
    for batch_idx, (data, target) in enumerate(train_set):
        print(batch_idx, batch_idx.shape)
        print(data, target)

        quit()
        data, target = Variable(data), Variable(target)
        optimizer.zero_grad()
        output = model(data, args.blocks)
        loss = criterion(output, target)
        loss.backward()
        optimizer.step()

        if batch_idx % 10 == 0:
            print('Train Epoch: {} [{}/{} ({:.0f}%)]\tLoss: {:.6f}'.format(
                epoch, batch_idx * len(data), len(train_set.dataset), 100. * batch_idx / len(train_set), loss.data[0]))


Can someone of you help me in understanding why this error occurs and why it seems that the Dataloader applied on my data (molecules) seems to return an object and not a tensor?
I am sorry if the question might seems obvious or dumb but as I said I am new to PyTorch and I am trying to improve!
Thanks a lot in advance! 
Kim