当前位置: 首页>>代码示例>>Python>>正文


Python Gaussian.reshape方法代码示例

本文整理汇总了Python中cle.cle.cost.Gaussian.reshape方法的典型用法代码示例。如果您正苦于以下问题:Python Gaussian.reshape方法的具体用法?Python Gaussian.reshape怎么用?Python Gaussian.reshape使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在cle.cle.cost.Gaussian的用法示例。


在下文中一共展示了Gaussian.reshape方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: Gaussian

# 需要导入模块: from cle.cle.cost import Gaussian [as 别名]
# 或者: from cle.cle.cost.Gaussian import reshape [as 别名]
for k, v in updates.iteritems():
    k.default_update = v

s_t = s_t[:-1]
s_shape = s_t.shape
s_in = T.concatenate([s_0, s_t.reshape((s_shape[0]*s_shape[1], -1))], axis=0)
theta_1_in = theta_1.fprop([s_in])
theta_2_in = theta_2.fprop([theta_1_in])
theta_3_in = theta_3.fprop([theta_2_in])
theta_4_in = theta_4.fprop([theta_3_in])
theta_mu_in = theta_mu.fprop([theta_4_in])
theta_sig_in = theta_sig.fprop([theta_4_in])

recon = Gaussian(x_in, theta_mu_in, theta_sig_in)
recon = recon.reshape((x_shape[0], x_shape[1]))
recon = recon * x_mask
recon_term = recon.sum(axis=0).mean()
recon_term.name = 'nll'

max_x = x.max()
mean_x = x.mean()
min_x = x.min()
max_x.name = 'max_x'
mean_x.name = 'mean_x'
min_x.name = 'min_x'

max_theta_mu = theta_mu_in.max()
mean_theta_mu = theta_mu_in.mean()
min_theta_mu = theta_mu_in.min()
max_theta_mu.name = 'max_theta_mu'
开发者ID:anirudh9119,项目名称:SpeechSyn,代码行数:32,代码来源:m0.py

示例2: Gaussian

# 需要导入模块: from cle.cle.cost import Gaussian [as 别名]
# 或者: from cle.cle.cost.Gaussian import reshape [as 别名]
((s_t, s_t_is, kl_t, theta_mu_t, theta_sig_t, mll), updates) =\
    theano.scan(fn=inner_fn,
                sequences=[x],
                outputs_info=[main_lstm.get_init_state(batch_size),
                              main_lstm.get_init_state(batch_size*num_sample),
                              None, None, None, None])

for k, v in updates.iteritems():
    k.default_update = v

reshaped_x = x.reshape((x.shape[0]*x.shape[1], -1))
reshaped_theta_mu = theta_mu_t.reshape((theta_mu_t.shape[0]*theta_mu_t.shape[1], -1))
reshaped_theta_sig = theta_sig_t.reshape((theta_sig_t.shape[0]*theta_sig_t.shape[1], -1))

recon = Gaussian(reshaped_x, reshaped_theta_mu, reshaped_theta_sig)
recon = recon.reshape((theta_mu_t.shape[0], theta_mu_t.shape[1]))
recon = recon * x_mask
kl_t = kl_t * x_mask
recon_term = recon.sum(axis=0).mean()
kl_term = kl_t.sum(axis=0).mean()

nll_lower_bound = recon_term + kl_term
nll_lower_bound.name = 'nll_lower_bound'

mll = mll * x_mask
mll = -mll.sum(axis=0).mean()
mll.name = 'marginal_nll'

outputs = [mll, nll_lower_bound]
monitor_fn = theano.function(inputs=[x, x_mask],
                     outputs=outputs,
开发者ID:anirudh9119,项目名称:SpeechSyn,代码行数:33,代码来源:test_m2_prior.py

示例3: inner_fn

# 需要导入模块: from cle.cle.cost import Gaussian [as 别名]
# 或者: from cle.cle.cost.Gaussian import reshape [as 别名]
def inner_fn(x_t, s_tm1, s_tm1_is):

    x_1_t = x_1.fprop([x_t])
    x_2_t = x_2.fprop([x_1_t])
    x_3_t = x_3.fprop([x_2_t])
    x_4_t = x_4.fprop([x_3_t])
    x_5_t = x_5.fprop([x_4_t])
    x_6_t = x_6.fprop([x_5_t])
 
    phi_1_t = phi_1.fprop([x_6_t, s_tm1])
    phi_2_t = phi_2.fprop([phi_1_t])
    phi_3_t = phi_3.fprop([phi_2_t])
    phi_4_t = phi_4.fprop([phi_3_t])
    phi_mu_t = phi_mu.fprop([phi_4_t])
    phi_sig_t = phi_sig.fprop([phi_4_t])

    z_t = prior.fprop([phi_mu_t, phi_sig_t])
    kl_t = kl.fprop([phi_mu_t, phi_sig_t])

    z_1_t = z_1.fprop([z_t])
    z_2_t = z_2.fprop([z_1_t])
    z_3_t = z_3.fprop([z_2_t])
    z_4_t = z_4.fprop([z_3_t])

    theta_1_t = theta_1.fprop([z_4_t, s_tm1])
    theta_2_t = theta_2.fprop([theta_1_t])
    theta_3_t = theta_3.fprop([theta_2_t])
    theta_4_t = theta_4.fprop([theta_3_t])
    theta_mu_t = theta_mu.fprop([theta_4_t])
    theta_sig_t = theta_sig.fprop([theta_4_t])

    s_t = main_lstm.fprop([[x_6_t, z_4_t], [s_tm1]])

    x_t_is = T.repeat(x_t, num_sample, axis=0)
    x_1_t_is = x_1.fprop([x_t_is])
    x_2_t_is = x_2.fprop([x_1_t_is])
    x_3_t_is = x_3.fprop([x_2_t_is])
    x_4_t_is = x_4.fprop([x_3_t_is])
    x_5_t_is = x_5.fprop([x_4_t_is])
    x_6_t_is = x_6.fprop([x_5_t_is])
 
    phi_1_t_is = phi_1.fprop([x_6_t_is, s_tm1_is])
    phi_2_t_is = phi_2.fprop([phi_1_t_is])
    phi_3_t_is = phi_3.fprop([phi_2_t_is])
    phi_4_t_is = phi_4.fprop([phi_3_t_is])
    phi_mu_t_is = phi_mu.fprop([phi_4_t_is])
    phi_sig_t_is = phi_sig.fprop([phi_4_t_is])

    z_t_is = prior.sample([phi_mu_t_is, phi_sig_t_is])
    z_1_t_is = z_1.fprop([z_t_is])
    z_2_t_is = z_2.fprop([z_1_t_is])
    z_3_t_is = z_3.fprop([z_2_t_is])
    z_4_t_is = z_4.fprop([z_3_t_is])
    prior_mu_t_is = T.zeros_like(z_t_is)
    prior_sig_t_is = T.ones_like(z_t_is)

    theta_1_t_is = theta_1.fprop([z_4_t_is, s_tm1_is])
    theta_2_t_is = theta_2.fprop([theta_1_t_is])
    theta_3_t_is = theta_3.fprop([theta_2_t_is])
    theta_4_t_is = theta_4.fprop([theta_3_t_is])
    theta_mu_t_is = theta_mu.fprop([theta_4_t_is])
    theta_sig_t_is = theta_sig.fprop([theta_4_t_is])
    mll = Gaussian(x_t_is, theta_mu_t_is, theta_sig_t_is) +\
          Gaussian(z_t_is, prior_mu_t_is, prior_sig_t_is) -\
          Gaussian(z_t_is, phi_mu_t_is, phi_sig_t_is)
    mll = mll.reshape((batch_size, num_sample))
    mll = logsumexp(-mll, axis=1) - T.log(num_sample)

    s_t_is = main_lstm.fprop([[x_6_t_is, z_4_t_is], [s_tm1_is]])

    return s_t, s_t_is, kl_t, theta_mu_t, theta_sig_t, mll
开发者ID:anirudh9119,项目名称:SpeechSyn,代码行数:73,代码来源:test_m2_prior.py

示例4: Gaussian

# 需要导入模块: from cle.cle.cost import Gaussian [as 别名]
# 或者: from cle.cle.cost.Gaussian import reshape [as 别名]
theta_2_in = theta_2.fprop([theta_1_in])
theta_3_in = theta_3.fprop([theta_2_in])
theta_4_in = theta_4.fprop([theta_3_in])
theta_mu_in = theta_mu.fprop([theta_4_in])
theta_sig_in = theta_sig.fprop([theta_4_in])

z_shape = phi_mu_t.shape
phi_mu_in = phi_mu_t.reshape((z_shape[0]*z_shape[1], -1))
phi_sig_in = phi_sig_t.reshape((z_shape[0]*z_shape[1], -1))
prior_mu_in = prior_mu_t.reshape((z_shape[0]*z_shape[1], -1))
prior_sig_in = prior_sig_t.reshape((z_shape[0]*z_shape[1], -1))
kl_in = kl.fprop([phi_mu_in, phi_sig_in, prior_mu_in, prior_sig_in])
kl_t = kl_in.reshape((z_shape[0], z_shape[1]))

recon = Gaussian(x_in, theta_mu_in, theta_sig_in)
recon = recon.reshape((x_shape[0], x_shape[1]))
recon_term = recon.mean()
kl_term = kl_t.mean()
nll_lower_bound = recon_term + kl_term
nll_lower_bound.name = 'nll_lower_bound'

mn_x_shape = mn_x.shape
mn_x_in = mn_x.reshape((mn_x_shape[0]*mn_x_shape[1], -1))
mn_x_1_in = x_1.fprop([mn_x_in])
mn_x_2_in = x_2.fprop([mn_x_1_in])
mn_x_3_in = x_3.fprop([mn_x_2_in])
mn_x_4_in = x_4.fprop([mn_x_3_in])
mn_x_4_in = mn_x_4_in.reshape((mn_x_shape[0], mn_x_shape[1], -1))
mn_s_0 = main_lstm.get_init_state(mn_batch_size)

((mn_s_t, mn_phi_mu_t, mn_phi_sig_t, mn_prior_mu_t, mn_prior_sig_t, mn_z_4_t), mn_updates) =\
开发者ID:anirudh9119,项目名称:SpeechSyn,代码行数:33,代码来源:m2.py


注:本文中的cle.cle.cost.Gaussian.reshape方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。