Пример #1
0
# <headingcell level=2>

# Proposal: RBF on sigmoid layer

# <codecell>

# check kernel
x=post(np.array([[11, 21, 31], [12, 22, 32]]))
y=post(np.array([[101, 201],   [102, 202]]))
l=post(np.array([[100]]))

tx = T.matrix('x')
ty = T.matrix('y')
tl = T.matrix('l')
f_kernel_matrix = function([tx, ty, tl], StackedRBF.kernel_matrix(tx, ty, tl))

K = f_kernel_matrix(x, y, l)
print gather(K)

# <codecell>

# hyperparameters
n_targets = RZ.get_value().shape[0]
n_features = RX.get_value().shape[0]
n_samples = RX.get_value().shape[1]
n_hidden = 50
#n_pivots = int(n_samples / 2)
n_pivots = 200

# <codecell>
Пример #2
0
#np.random.seed(100)
#RX, RZ, VX, VZ, TX, TZ = ml.common.util.load_theano_data('../datasets/boston_split.mat')
#RX, RZ, VX, VZ, TX, TZ = ml.common.util.load_theano_data('../datasets/abalone_split.mat')

# check kernel
x=floatx(np.array([[11, 21, 31], [12, 22, 32]]))
y=floatx(np.array([[101, 201],   [102, 202]]))
x=gp.as_garray(x)
y=gp.as_garray(y)
l = gp.as_garray([[100]])


tx = T.matrix('x')
ty = T.matrix('y')
tl = T.matrix('l')
f_kernel_matrix = function([tx, ty, tl], StackedRBF.kernel_matrix(tx, ty, tl))


K = f_kernel_matrix(x, y, l)
print K


tsq = T.sum(tx**2)
f_sq = function([tx], tsq)
print f_sq(gp.as_garray([[5]]))


gsq = T.grad(tsq, [tx])
f_gsq = function([tx], gsq)
print f_gsq(gp.as_garray([[5]]))