|
|
|
@ -173,9 +173,9 @@ class OtherLayerTest(unittest.TestCase):
|
|
|
|
|
|
|
|
|
|
class ProjOpTest(unittest.TestCase):
|
|
|
|
|
def test_projection(self):
|
|
|
|
|
input = layer.data(name='data', type=data_type.dense_vector(784))
|
|
|
|
|
input = layer.data(name='data2', type=data_type.dense_vector(784))
|
|
|
|
|
word = layer.data(
|
|
|
|
|
name='word', type=data_type.integer_value_sequence(10000))
|
|
|
|
|
name='word2', type=data_type.integer_value_sequence(10000))
|
|
|
|
|
fc0 = layer.fc(input=input, size=100, act=activation.Sigmoid())
|
|
|
|
|
fc1 = layer.fc(input=input, size=200, act=activation.Sigmoid())
|
|
|
|
|
mixed0 = layer.mixed(
|
|
|
|
@ -204,8 +204,8 @@ class ProjOpTest(unittest.TestCase):
|
|
|
|
|
dotmul1 += dotmul
|
|
|
|
|
|
|
|
|
|
context = layer.context_projection(input=fc0, context_len=5)
|
|
|
|
|
context0 = layer.mixed(size=100, input=context)
|
|
|
|
|
with layer.mixed(size=100) as context1:
|
|
|
|
|
context0 = layer.mixed(size=500, input=context)
|
|
|
|
|
with layer.mixed(size=500) as context1:
|
|
|
|
|
context1 += context
|
|
|
|
|
|
|
|
|
|
conv = layer.conv_projection(
|
|
|
|
@ -231,8 +231,8 @@ class ProjOpTest(unittest.TestCase):
|
|
|
|
|
print layer.parse_network(conv1)
|
|
|
|
|
|
|
|
|
|
def test_operator(self):
|
|
|
|
|
ipt0 = layer.data(name='data', type=data_type.dense_vector(784))
|
|
|
|
|
ipt1 = layer.data(name='word', type=data_type.dense_vector(128))
|
|
|
|
|
ipt0 = layer.data(name='data1', type=data_type.dense_vector(784))
|
|
|
|
|
ipt1 = layer.data(name='word1', type=data_type.dense_vector(128))
|
|
|
|
|
fc0 = layer.fc(input=ipt0, size=100, act=activation.Sigmoid())
|
|
|
|
|
fc1 = layer.fc(input=ipt0, size=100, act=activation.Sigmoid())
|
|
|
|
|
|
|
|
|
@ -261,7 +261,7 @@ class ProjOpTest(unittest.TestCase):
|
|
|
|
|
|
|
|
|
|
class NetworkTests(unittest.TestCase):
|
|
|
|
|
def test_vgg(self):
|
|
|
|
|
img = layer.data(name='pixel', type=data_type.dense_vector(784))
|
|
|
|
|
img = layer.data(name='pixel1', type=data_type.dense_vector(784))
|
|
|
|
|
vgg_out = networks.small_vgg(
|
|
|
|
|
input_image=img, num_channels=1, num_classes=2)
|
|
|
|
|
print layer.parse_network(vgg_out)
|
|
|
|
@ -269,12 +269,12 @@ class NetworkTests(unittest.TestCase):
|
|
|
|
|
|
|
|
|
|
class EvaluatorTest(unittest.TestCase):
|
|
|
|
|
def test_evaluator(self):
|
|
|
|
|
img = layer.data(name='pixel', type=data_type.dense_vector(784))
|
|
|
|
|
img = layer.data(name='pixel2', type=data_type.dense_vector(784))
|
|
|
|
|
output = layer.fc(input=img,
|
|
|
|
|
size=10,
|
|
|
|
|
act=activation.Softmax(),
|
|
|
|
|
name='fc_here')
|
|
|
|
|
lbl = layer.data(name='label', type=data_type.integer_value(10))
|
|
|
|
|
lbl = layer.data(name='label2', type=data_type.integer_value(10))
|
|
|
|
|
cost = layer.cross_entropy_cost(input=output, label=lbl)
|
|
|
|
|
|
|
|
|
|
evaluator.classification_error(input=output, label=lbl)
|
|
|
|
|