more offering to overlord
@@ -2,14 +2,10 @@ import pytest
import torch
from torch.autograd import Variable
import torch.nn as nn
-from torch.nn import Parameter
import pyro
import pyro.distributions as dist
import pyro.optim
-from pyro import poutine
-from pyro.infer.enum import iter_discrete_traces, scale_trace
-from tests.common import assert_equal
class outest(nn.Module):
@@ -23,6 +19,7 @@ class outest(nn.Module):
def forward(self, s):
pass
+
class outer(torch.nn.Module):
def __init__(self):
@@ -33,6 +30,7 @@ class outer(torch.nn.Module):
def forward(self, s):
pass
+
class inner(torch.nn.Module):
def __init__(self):
@@ -43,12 +41,14 @@ class inner(torch.nn.Module):
def forward(self, s):
pass
+
sequential = nn.Sequential(
nn.Conv2d(1, 20, 5),
nn.ReLU(),
nn.Conv2d(20, 64, 5)
)
+
@pytest.mark.parametrize("nn_module", [outest, outer])
def test_module_nn(nn_module):
pyro.clear_param_store()
@@ -58,6 +58,7 @@ def test_module_nn(nn_module):
for name in pyro.get_param_store().get_all_param_names():
assert pyro.params.user_param_name(name) in nn_module.state_dict().keys()
+
@pytest.mark.parametrize("nn_module", [sequential])
def test_module_sequential(nn_module):
pyro.clear_param_store()
@@ -66,6 +67,7 @@ def test_module_sequential(nn_module):
for name in pyro.get_param_store().get_all_param_names():
assert pyro.params.user_param_name(name) in nn_module.state_dict().keys()
+
@pytest.mark.parametrize("nn_module", [outest, outer])
def test_random_module(nn_module):
pyro.clear_param_store()
