Closed ivan-chai closed 4 months ago
И еще тесты ппадают с такой ошибкой:
================================================================================== FAILURES ===================================================================================
_____________________________________________________________________________ test_padded_collate _____________________________________________________________________________
def test_padded_collate():
data = [
({'a': torch.LongTensor([1, 2, 3, 4])}, torch.LongTensor([0])),
({'a': torch.LongTensor([1, 2])}, torch.LongTensor([0])),
({'a': torch.LongTensor([1])}, torch.LongTensor([1])),
]
tt = torch.LongTensor([
[1, 2, 3, 4],
[1, 2, 0, 0],
[1, 0, 0, 0]])
> x, y = padded_collate(data)
ptls_tests/test_data_load/test__init__.py:21:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
batch = [({'a': tensor([1, 2, 3, 4])}, tensor([0])), ({'a': tensor([1, 2])}, tensor([0])), ({'a': tensor([1])}, tensor([1]))]
def padded_collate(batch):
new_x_ = defaultdict(list)
for x, _ in batch:
for k, v in x.items():
new_x_[k].append(v)
lengths = torch.IntTensor([len(e) for e in next(iter(new_x_.values()))])
new_x = {k: torch.nn.utils.rnn.pad_sequence(v, batch_first=True) for k, v in new_x_.items()}
> new_y = np.array([y for _, y in batch])
E ValueError: setting an array element with a sequence. The requested array has an inhomogeneous shape after 1 dimensions. The detected shape was (3,) + inhomogeneous part.
ptls/data_load/__init__.py:347: ValueError
============================================================================== warnings summary ===============================================================================
Тест вроде бы должен работать теперь.