missing_param = None
rng = numpy.random.RandomState(1234)
input = T.matrix('input')
X = numpy.asarray(rng.uniform(low=-2.1, high=5.0, size=(batch_s, dims)))
W = theano.shared(value=numpy.asarray(rng.uniform(low=0.001, high=1.0, size
    =(dims, hidd_s)), dtype=theano.config.floatX), name='W', borrow=True)
S = theano.shared(value=numpy.asarray(rng.uniform(low=10.0, high=100.0,
    size=(hidd_s,)), dtype=theano.config.floatX), name='S', borrow=True)
f_func, f_updates = theano.map(lambda i: T.exp(-(W.T - i).norm(2, axis=1) **
    2) / 2 * S ** 2, input, [])
layer_out = theano.function([input], f_func, updates=f_updates,
    on_unused_input=missing_param, allow_input_downcast=True)
print(layer_out(X.astype('float32')))
stop = timeit.default_timer()
print('running time: ' + str(stop - start))
efficient kernel implementation in theano