Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Data fixes and readme update (#1136)
* readme * batch overfit fix for reproducibility * batch overfit fix for reproducibility
- Loading branch information
Showing
6 changed files
with
54 additions
and
38 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
# flake8: noqa | ||
import torch | ||
from torch.utils.data import DataLoader, TensorDataset | ||
|
||
from catalyst.data.loader import BatchLimitLoaderWrapper | ||
|
||
|
||
def test_batch_limit1() -> None: | ||
for shuffle in (False, True): | ||
num_samples, num_features = int(1e2), int(1e1) | ||
X, y = torch.rand(num_samples, num_features), torch.rand(num_samples) | ||
dataset = TensorDataset(X, y) | ||
loader = DataLoader(dataset, batch_size=4, num_workers=1, shuffle=shuffle) | ||
loader = BatchLimitLoaderWrapper(loader, num_batches=1) | ||
|
||
batch1 = next(iter(loader))[0] | ||
batch2 = next(iter(loader))[0] | ||
batch3 = next(iter(loader))[0] | ||
assert all(torch.isclose(x, y).all() for x, y in zip(batch1, batch2)) | ||
assert all(torch.isclose(x, y).all() for x, y in zip(batch2, batch3)) | ||
|
||
|
||
def test_batch_limit2() -> None: | ||
for shuffle in (False, True): | ||
num_samples, num_features = int(1e2), int(1e1) | ||
X, y = torch.rand(num_samples, num_features), torch.rand(num_samples) | ||
dataset = TensorDataset(X, y) | ||
loader = DataLoader(dataset, batch_size=4, num_workers=1, shuffle=shuffle) | ||
loader = BatchLimitLoaderWrapper(loader, num_batches=2) | ||
|
||
batch1 = next(iter(loader))[0] | ||
batch2 = next(iter(loader))[0] | ||
batch3 = next(iter(loader))[0] | ||
batch4 = next(iter(loader))[0] | ||
assert all(torch.isclose(x, y).all() for x, y in zip(batch1, batch3)) | ||
assert all(torch.isclose(x, y).all() for x, y in zip(batch2, batch4)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters