本文整理汇总了Python中chainer.Variable.data[0,0,:,0]方法的典型用法代码示例。如果您正苦于以下问题:Python Variable.data[0,0,:,0]方法的具体用法?Python Variable.data[0,0,:,0]怎么用?Python Variable.data[0,0,:,0]使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类chainer.Variable
的用法示例。
在下文中一共展示了Variable.data[0,0,:,0]方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: sim
# 需要导入模块: from chainer import Variable [as 别名]
# 或者: from chainer.Variable import data[0,0,:,0] [as 别名]
def sim():
zeta0 = (np.random.uniform(-10.0, 10.0, (1,1,H,W)).astype(np.float32))
zeta0 = Variable(chainer.cuda.to_gpu(zeta0.astype(np.float32)), volatile=True)
for it in range(100):
zeta0 += 0.1*lap.forward(zeta0)
zeta = 0.0 + zeta0
psi = poisson_jacobi(zeta, num_iter=1000)
rho = Variable(rho0, volatile=True)
for i in range(10000):
psi = poisson_jacobi(zeta, x0=psi)
dpdx = FTCS_X().forward(psi) # -vy
dpdy = FTCS_Y().forward(psi) # vx
dzdx = upwind(Kawamura_X().forward(zeta), dpdy)
dzdy = upwind(Kawamura_Y().forward(zeta), -dpdx)
lapz = lap.forward(zeta)
rho_ = rho-0.5*dt*(dpdy*upwind(Kawamura_X().forward(rho), dpdy)-dpdx*upwind(Kawamura_Y().forward(rho), -dpdx) - 0.000*lap.forward(rho))
rho_.data[0,0,:,0] = rho_.data[0,0,:,499]
sum_rho = chainer.functions.sum(rho_)
rho_ = rho_/(xp.zeros_like(rho.data)+sum_rho)
dzdt = dpdx*dzdy - dpdy*dzdx + nu*lapz
zeta_ = zeta+0.5*dt * dzdt
psi = poisson_jacobi(zeta_, x0=psi)
dpdx = FTCS_X().forward(psi) # -vy
dpdy = FTCS_Y().forward(psi) # vx
dzdx = upwind(Kawamura_X().forward(zeta_), dpdy)
dzdy = upwind(Kawamura_Y().forward(zeta_), -dpdx)
lapz = lap.forward(zeta_)
rho = rho - dt*(dpdy*upwind(Kawamura_X().forward(rho_), dpdy)-dpdx*upwind(Kawamura_Y().forward(rho_), -dpdx) - 0.000*lap.forward(rho_))
rho.data[0,0,:,0] = rho.data[0,0,:,499]
sum_rho = chainer.functions.sum(rho)
rho = rho/(xp.zeros_like(rho.data)+sum_rho)
dzdt = dpdx*dzdy - dpdy*dzdx + nu*lapz
zeta = zeta + dt * dzdt
if i%10==0:
yield zeta, psi, rho, i