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!
Nelze vybrat více než 25 témat Téma musí začínat písmenem nebo číslem, může obsahovat pomlčky („-“) a může být dlouhé až 35 znaků.

test_layer_decode.py 844B

12345678910111213141516171819202122
  1. from decagon_pytorch.layer import OneHotInputLayer, \
  2. DecagonLayer, \
  3. DecodeLayer
  4. from decagon_pytorch.decode.cartesian import DEDICOMDecoder
  5. from decagon_pytorch.data import Data
  6. import torch
  7. def test_decode_layer_01():
  8. d = Data()
  9. d.add_node_type('Dummy', 100)
  10. d.add_relation_type('Dummy Relation 1', 0, 0,
  11. torch.rand((100, 100), dtype=torch.float32).round().to_sparse())
  12. in_layer = OneHotInputLayer(d)
  13. d_layer = DecagonLayer(d, in_layer, 32)
  14. last_layer_repr = d_layer()
  15. dec = DecodeLayer(d, last_layer = d_layer, decoder_class = DEDICOMDecoder)
  16. pred_adj_matrices = dec(last_layer_repr)
  17. assert isinstance(pred_adj_matrices, dict)
  18. assert len(pred_adj_matrices) == 1
  19. assert isinstance(pred_adj_matrices[0, 0], list)
  20. assert len(pred_adj_matrices[0, 0]) == 1