def test_flattener_layer_state_separation_for_conv():
 conv1 = ConvElemwise(8, [2, 2], 'sf1', SigmoidConvNonlinearity(), 0.1)
 conv2 = ConvElemwise(8, [2, 2], 'sf2', SigmoidConvNonlinearity(), 0.1)
 mlp = MLP(layers=[FlattenerLayer(CompositeLayer('comp', [conv1, conv2]))], input_space=Conv2DSpace(shape=[5, 5], num_channels=2))
 topo_view = np.random.rand(10, 5, 5, 2).astype(theano.config.floatX)
 y = np.random.rand(10, 256).astype(theano.config.floatX)
 dataset = DenseDesignMatrix(topo_view=topo_view, y=y)
 train = Train(dataset, mlp, SGD(0.1, batch_size=5, monitoring_dataset=dataset))
 train.algorithm.termination_criterion = EpochCounter(1)
 train.main_loop()

def test_flattener_layer_state_separation_for_conv ( ) : conv1 = ConvElemwise ( 8 , [ 2 , 2 ] , 'sf1' , SigmoidConvNonlinearity ( ) , 0.1 ) conv2 = ConvElemwise ( 8 , [ 2 , 2 ] , 'sf2' , SigmoidConvNonlinearity ( ) , 0.1 ) mlp = MLP ( layers = [ FlattenerLayer ( CompositeLayer ( 'comp' , [ conv1 , conv2 ] ) ) ] , input_space = Conv2DSpace ( shape = [ 5 , 5 ] , num_channels = 2 ) ) topo_view = np . random . rand ( 10 , 5 , 5 , 2 ) . astype ( theano . config . floatX ) y = np . random . rand ( 10 , 256 ) . astype ( theano . config . floatX ) dataset = DenseDesignMatrix ( topo_view = topo_view , y = y ) train = Train ( dataset , mlp , SGD ( 0.1 , batch_size = 5 , monitoring_dataset = dataset ) ) train . algorithm . termination_criterion = EpochCounter ( 1 ) train . main_loop ( )
creates a compositelayer wrapping two conv layers and ensures that state gets correctly picked apart .