Browse Source

change error type

tags/v0.3.0-alpha
zhaojichen 6 years ago
parent
commit
1af894e25f
4 changed files with 18 additions and 18 deletions
  1. +6
    -6
      tests/ut/python/nn/test_dynamic_lr.py
  2. +1
    -1
      tests/ut/python/nn/test_psnr.py
  3. +1
    -1
      tests/ut/python/nn/test_ssim.py
  4. +10
    -10
      tests/ut/python/ops/test_nn_ops.py

+ 6
- 6
tests/ut/python/nn/test_dynamic_lr.py View File

@@ -32,7 +32,7 @@ power = 0.5
class TestInputs:
def test_milestone1(self):
milestone1 = 1
with pytest.raises(ValueError):
with pytest.raises(TypeError):
dr.piecewise_constant_lr(milestone1, learning_rates)

def test_milestone2(self):
@@ -46,12 +46,12 @@ class TestInputs:

def test_learning_rates1(self):
lr = True
with pytest.raises(ValueError):
with pytest.raises(TypeError):
dr.piecewise_constant_lr(milestone, lr)

def test_learning_rates2(self):
lr = [1, 2, 1]
with pytest.raises(ValueError):
with pytest.raises(TypeError):
dr.piecewise_constant_lr(milestone, lr)

def test_learning_rate_type(self):
@@ -158,7 +158,7 @@ class TestInputs:

def test_is_stair(self):
is_stair = 1
with pytest.raises(ValueError):
with pytest.raises(TypeError):
dr.exponential_decay_lr(learning_rate, decay_rate, total_step, step_per_epoch, decay_epoch, is_stair)

def test_min_lr_type(self):
@@ -183,12 +183,12 @@ class TestInputs:

def test_power(self):
power1 = True
with pytest.raises(ValueError):
with pytest.raises(TypeError):
dr.polynomial_decay_lr(learning_rate, end_learning_rate, total_step, step_per_epoch, decay_epoch, power1)

def test_update_decay_epoch(self):
update_decay_epoch = 1
with pytest.raises(ValueError):
with pytest.raises(TypeError):
dr.polynomial_decay_lr(learning_rate, end_learning_rate, total_step, step_per_epoch, decay_epoch,
power, update_decay_epoch)



+ 1
- 1
tests/ut/python/nn/test_psnr.py View File

@@ -52,7 +52,7 @@ def test_psnr_max_val_negative():

def test_psnr_max_val_bool():
max_val = True
with pytest.raises(ValueError):
with pytest.raises(TypeError):
net = PSNRNet(max_val)

def test_psnr_max_val_zero():


+ 1
- 1
tests/ut/python/nn/test_ssim.py View File

@@ -51,7 +51,7 @@ def test_ssim_max_val_negative():

def test_ssim_max_val_bool():
max_val = True
with pytest.raises(ValueError):
with pytest.raises(TypeError):
net = SSIMNet(max_val)

def test_ssim_max_val_zero():


+ 10
- 10
tests/ut/python/ops/test_nn_ops.py View File

@@ -528,7 +528,7 @@ test_cases_for_verify_exception = [
'desc_inputs': [0],
}),
('MaxPoolWithArgmax_ValueError_2', {
'block': (lambda _: P.MaxPoolWithArgmax(ksize='1'), {'exception': ValueError}),
'block': (lambda _: P.MaxPoolWithArgmax(ksize='1'), {'exception': TypeError}),
'desc_inputs': [0],
}),
('MaxPoolWithArgmax_ValueError_3', {
@@ -560,31 +560,31 @@ test_cases_for_verify_exception = [
'desc_inputs': [0],
}),
('Softmax_ValueError_1', {
'block': (lambda _: P.Softmax("1"), {'exception': ValueError}),
'block': (lambda _: P.Softmax("1"), {'exception': TypeError}),
'desc_inputs': [0],
}),
('Softmax_ValueError_2', {
'block': (lambda _: P.Softmax(1.1), {'exception': ValueError}),
'block': (lambda _: P.Softmax(1.1), {'exception': TypeError}),
'desc_inputs': [0],
}),
('Softmax_ValueError_3', {
'block': (lambda _: P.Softmax(axis="1"), {'exception': ValueError}),
'block': (lambda _: P.Softmax(axis="1"), {'exception': TypeError}),
'desc_inputs': [0],
}),
('DropoutGenMask_ValueError_1', {
'block': (lambda _: P.DropoutGenMask(Seed0="seed0"), {'exception': ValueError}),
'block': (lambda _: P.DropoutGenMask(Seed0="seed0"), {'exception': TypeError}),
'desc_inputs': [0],
}),
('DropoutGenMask_ValueError_2', {
'block': (lambda _: P.DropoutGenMask(Seed0=1.0), {'exception': ValueError}),
'block': (lambda _: P.DropoutGenMask(Seed0=1.0), {'exception': TypeError}),
'desc_inputs': [0],
}),
('DropoutGenMask_ValueError_3', {
'block': (lambda _: P.DropoutGenMask(Seed1="seed1"), {'exception': ValueError}),
'block': (lambda _: P.DropoutGenMask(Seed1="seed1"), {'exception': TypeError}),
'desc_inputs': [0],
}),
('DropoutGenMask_ValueError_4', {
'block': (lambda _: P.DropoutGenMask(Seed1=2.0), {'exception': ValueError}),
'block': (lambda _: P.DropoutGenMask(Seed1=2.0), {'exception': TypeError}),
'desc_inputs': [0],
}),
('MaxPool2d_ValueError_1', {
@@ -594,14 +594,14 @@ test_cases_for_verify_exception = [
('MaxPool2d_ValueError_2', {
'block': (
lambda _: nn.MaxPool2d(kernel_size=120, stride=True, pad_mode="valid"),
{'exception': ValueError},
{'exception': TypeError},
),
'desc_inputs': [Tensor(np.random.randn(32, 3, 112, 112).astype(np.float32).transpose(0, 3, 1, 2))],
}),
('MaxPool2d_ValueError_3', {
'block': (
lambda _: nn.MaxPool2d(kernel_size=3, stride=True, pad_mode="valid"),
{'exception': ValueError},
{'exception': TypeError},
),
'desc_inputs': [Tensor(np.random.randn(32, 3, 112, 112).astype(np.float32).transpose(0, 3, 1, 2))],
}),


Loading…
Cancel
Save