def build_conv_nnet2_classif(use_gpu, isize, ksize, n_batch,
                             downsample_ops=True, verbose=0, version=-1,
                             check_isfinite=True):
    if use_gpu:
        shared_fn = tcn.shared_constructor
    else:
        shared_fn = shared

    isize1 = isize
    isize2 = isize
    if isinstance(isize, (tuple, )):
        isize1 = isize[0]
        isize2 = isize[1]

    shape_img = (n_batch, 1, isize1, isize2)

    n_kern = 20  # 6 were used in LeNet5
    shape_kern = (n_kern, 1, ksize, ksize)

    n_kern1 = 30  # 16 were used in LeNet5
    shape_kern1 = (n_kern1, n_kern, ksize, ksize)

    logical_hid_shape = tcn.blas.GpuConv.logical_output_shape_2d(
        (isize1, isize2), (ksize, ksize), 'valid')
    logical_hid_shape1 = tcn.blas.GpuConv.logical_output_shape_2d(
        (logical_hid_shape[0] // 2, logical_hid_shape[1] // 2),
        (ksize, ksize), 'valid')
    n_hid = n_kern1 * logical_hid_shape1[0] * logical_hid_shape1[1]
    n_out = 10

    w0 = shared_fn(0.01 * (0.5 - my_rand(*shape_kern)), 'w0')
    b0 = shared_fn(my_zeros((n_kern,)), 'b0')
    w1 = shared_fn(0.01 * (my_rand(*shape_kern1) - 0.5), 'w1')
    b1 = shared_fn(my_zeros((n_kern1,)), 'b1')
    v = shared_fn(0.01 * my_randn(n_hid, n_out), 'v')
    c = shared_fn(my_zeros(n_out), 'c')

    # print 'ALLOCATING ARCH: w0 shape', w0.get_value(borrow=True).shape
    # print 'ALLOCATING ARCH: w1 shape', w1.get_value(borrow=True).shape
    # print 'ALLOCATING ARCH: v shape', v.get_value(borrow=True).shape

    x = tensor.Tensor(dtype='float32', broadcastable=(0, 1, 0, 0))('x')
    y = tensor.fmatrix('y')
    lr = tensor.fscalar('lr')

    conv_op = conv.ConvOp(shape_img[2:], shape_kern[2:], n_kern,
                          n_batch, 1, 1, verbose=verbose, version=version)
    conv_op1 = conv.ConvOp(
        (n_kern, logical_hid_shape[0] // 2, logical_hid_shape[1] // 2),
        shape_kern1[2:], n_kern1, n_batch, 1, 1, verbose=verbose, version=version)

    ds_op = pool.Pool((2, 2), ignore_border=False)
    if downsample_ops:
        hid = tensor.tanh(ds_op(conv_op(x, w0) + b0.dimshuffle((0, 'x', 'x'))))
    else:
        hid = tensor.tanh((conv_op(x, w0) + b0.dimshuffle((0, 'x', 'x')
            ))[:, :, ::2, ::2])
    hid1 = tensor.tanh(conv_op1(hid, w1) + b1.dimshuffle((0, 'x', 'x')))
    hid_flat = hid1.reshape((n_batch, n_hid))
    out = tensor.nnet.softmax(tensor.dot(hid_flat, v) + c)
    loss = tensor.sum(tensor.nnet.crossentropy_categorical_1hot(out,
         tensor.argmax(y, axis=1)) * lr)
    # print 'loss type', loss.type

    params = [w0, b0, w1, b1, v, c]
    gparams = tensor.grad(loss, params)

    mode = get_mode(use_gpu, check_isfinite)

    # print 'building pfunc ...'
    train = pfunc([x, y, lr], [loss], mode=mode, updates=[(p, p - g) for p,
        g in zip(params, gparams)])

    if verbose:
        theano.printing.debugprint(train)
    if use_gpu:
        # Check that GpuConv is used
        topo = train.maker.fgraph.toposort()
        conv_ops = (tcn.blas.GpuConv,
                    tcn.dnn.GpuDnnConv,
                    tcn.dnn.GpuDnnConvGradI,
                    tcn.dnn.GpuDnnConvGradW,
                    tcn.blas.BaseGpuCorrMM)

        assert len([n for n in topo if isinstance(n.op, conv_ops)]) > 0

    shape_target = (n_batch, n_out)
    return train, params, shape_img, shape_target, mode
dataset/ETHPy150Open rizar/attention-lvcsr/libs/Theano/theano/sandbox/cuda/tests/test_mlp.py/build_conv_nnet2_classif/swapped operands of `-`