cross_valid_example.py 462 B

1234567891011121314151617181920
  1. import torch
  2. from torch.utils.data import TensorDataset
  3. from draugr.torch_utilities import cross_validation_generator, to_tensor
  4. def asdasidoj():
  5. """
  6. """
  7. X = to_tensor([torch.diag(torch.arange(i, i + 2)) for i in range(200)])
  8. x_train = TensorDataset(X[:100])
  9. x_val = TensorDataset(X[100:])
  10. for train, val in cross_validation_generator(x_train, x_val):
  11. print(len(train), len(val))
  12. print(train[0], val[0])
  13. asdasidoj()