def test_withaxesswapped_dim0_dim1_eq(): X = tensor.matrix('X') brick = Linear(input_dim=2, output_dim=2, weights_init=Constant(1), biases_init=Constant(0)) wrapper = WithAxesSwapped(brick.apply, 0, 0) wrapper.initialize() brick.W.set_value( numpy.asarray([[1, 2], [1, 1]], dtype=theano.config.floatX)) f = theano.function([X], wrapper.apply(X)) assert_allclose( f(numpy.arange(4, dtype=theano.config.floatX).reshape((2, 2))), numpy.array([[1, 1], [5, 7]]))
def test_withaxesswapped_is_serializable(): brick = Linear(input_dim=2, output_dim=2, weights_init=Constant(1), biases_init=Constant(0)) wrapper = WithAxesSwapped(brick.apply, 0, 1) wrapper.initialize() cPickle.loads(cPickle.dumps(wrapper))