IF YOU WOULD LIKE TO GET AN ACCOUNT, please write an email to s dot adaszewski at gmail dot com. User accounts are meant only to report issues and/or generate pull requests. This is a purpose-specific Git hosting for ADARED projects. Thank you for your understanding!
Você não pode selecionar mais de 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.

test_dropout.py 738B

1234567891011121314151617181920212223242526
  1. from icosagon.dropout import dropout_sparse, \
  2. dropout_dense
  3. import torch
  4. import numpy as np
  5. def test_dropout_01():
  6. for i in range(11):
  7. torch.random.manual_seed(i)
  8. a = torch.rand((5, 10))
  9. a[a < .5] = 0
  10. keep_prob=i/10. + np.finfo(np.float32).eps
  11. torch.random.manual_seed(i)
  12. b = dropout_dense(a, keep_prob=keep_prob)
  13. torch.random.manual_seed(i)
  14. c = dropout_sparse(a.to_sparse(), keep_prob=keep_prob)
  15. print('keep_prob:', keep_prob)
  16. print('a:', a.detach().cpu().numpy())
  17. print('b:', b.detach().cpu().numpy())
  18. print('c:', c, c.to_dense().detach().cpu().numpy())
  19. assert torch.all(b == c.to_dense())