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!
Procházet zdrojové kódy

Add test_model_06().

master
Stanislaw Adaszewski před 4 roky
rodič
revize
414c93419f
2 změnil soubory, kde provedl 42 přidání a 0 odebrání
  1. +4
    -0
      src/icosagon/data.py
  2. +38
    -0
      tests/icosagon/test_model.py

+ 4
- 0
src/icosagon/data.py Zobrazit soubor

@@ -120,6 +120,10 @@ class RelationFamily(RelationFamilyBase):
adjacency_matrix.transpose(0, 1))):
raise ValueError('Relation family is symmetric but adjacency_matrix is assymetric')
if not self.is_symmetric and node_type_row != node_type_column and \
adjacency_matrix_backward is None:
raise ValueError('Relation is asymmetric but adjacency_matrix_backward is None')
if self.is_symmetric and node_type_row != node_type_column:
adjacency_matrix_backward = adjacency_matrix.transpose(0, 1)


+ 38
- 0
tests/icosagon/test_model.py Zobrazit soubor

@@ -10,6 +10,7 @@ import torch
from icosagon.input import OneHotInputLayer
from icosagon.convlayer import DecagonLayer
from icosagon.declayer import DecodeLayer
import pytest
def _is_identity_function(f):
@@ -147,3 +148,40 @@ def test_model_05():
assert len(list(m.seq[1].parameters())) == 6
assert len(list(m.seq[2].parameters())) == 6
assert len(list(m.seq[3].parameters())) == 6
def test_model_06():
d = Data()
d.add_node_type('Dummy', 10)
fam = d.add_relation_family('Dummy-Dummy', 0, 0, False)
fam.add_relation_type('Dummy Rel', torch.rand(10, 10).round())
with pytest.raises(TypeError):
m = Model(1)
with pytest.raises(TypeError):
m = Model(d, layer_dimensions=1)
with pytest.raises(TypeError):
m = Model(d, ratios=1)
with pytest.raises(ValueError):
m = Model(d, keep_prob='x')
with pytest.raises(TypeError):
m = Model(d, rel_activation='x')
with pytest.raises(TypeError):
m = Model(d, layer_activation='x')
with pytest.raises(TypeError):
m = Model(d, dec_activation='x')
with pytest.raises(ValueError):
m = Model(d, lr='x')
with pytest.raises(TypeError):
m = Model(d, loss=1)
with pytest.raises(ValueError):
m = Model(d, batch_size='x')

Načítá se…
Zrušit
Uložit