'ValueError: expected sequence of length 1300000 at dim 1 (got 650000)

Got a problem while converting in list to pytorch tensor. here is a code.

X_train, X_test, y_train, y_test = train_test_split(
    (db1_sig + db2_sig), 
    (db1_label + db2_label) * 2,
    test_size=0.33,
    shuffle=True
)

print()

train_dataloader = DataLoader(X_train,
                              batch_size=BATCH_SIZE,
                              num_workers=0, collate_fn=lambda x: x,
                              shuffle=True)

test_dataloader = DataLoader(X_test,
                             batch_size=BATCH_SIZE,
                             shuffle=True)

...


loss_ = []
for epoch in range(EPOCH):
    '''First bbrbm'''
    for _, (data) in enumerate(train_dataloader):
        try:
            data = Variable(torch.tensor(data, dtype=torch.float32)).uniform_(0, 1)
            print("Success")
        except ValueError:
            print("Fail")
            pass

        data = torch.tensor(data)

and here is the output of above code.

Fail

---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
/var/folders/_8/q_cwh5hn0s1dxsrzq2d040p80000gn/T/ipykernel_36555/515943032.py in <module>
     12             pass
     13 
---> 14         data = torch.tensor(data)
     15         sample_data = torch.bernoulli(data)
     16         sample_data = torch.flatten(sample_data.clone())

I still figuring out but I don't know why does it not work. Please give me any solutions.. thank you.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source