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


Python functions.tile方法代码示例

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


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

示例1: process_trajectory

# 需要导入模块: from chainer import functions [as 别名]
# 或者: from chainer.functions import tile [as 别名]
def process_trajectory(self, l):
        """This is the time-dependent convolution operation, applied to a trajectory (in order).
        """
        shp = l.shape[0]
        # First dim is batchsize=1, then either 1 channel for 2d conv or n_feat channels
        # for 1d conv.
        l = F.expand_dims(l, axis=0)
        l = F.transpose(l, (0, 2, 1))
        l = self.traj_c0(l)
        l = F.leaky_relu(l)
        l = self.traj_c1(l)
        l = F.leaky_relu(l)
        l = F.sum(l, axis=(0, 2)) / l.shape[0] / l.shape[2]
        l = F.expand_dims(l, axis=0)
        l = self.traj_d0(l)
        l = F.tile(l, (shp, 1))
        return l 
开发者ID:openai,项目名称:EPG,代码行数:19,代码来源:losses.py

示例2: __call__

# 需要导入模块: from chainer import functions [as 别名]
# 或者: from chainer.functions import tile [as 别名]
def __call__(self, x, *args):
        """
           Args:
               x (ndarray): Shape is (Batch * K, 7, t).
                            each set has (xi, yi, zi, ri, xi −vx, yi −vy, zi −vz).
                            vx, vy, vz is local mean at each voxel.
           Return:
               y (ndarray): Shape is (Batch * K, 128)
        """
        n_batch, n_channels, n_points = x.shape
        # mask = F.max(x, axis=(1, 2), keepdims=True).data != 0
        mask = F.max(x, axis=1, keepdims=True).data != 0
        active_length = 0 #mask.sum()

        # Convolution1D -> BN -> relu -> pool -> concat
        h = F.relu(self.bn1(self.conv1(x), active_length, mask))
        global_feat = F.max_pooling_nd(h, n_points)
        # Shape is (Batch, channel, points)
        global_feat_expand = F.tile(global_feat, (1, 1, n_points))
        h = F.concat((h, global_feat_expand))
        h *= mask

        h = self.conv2(h)
        return F.squeeze(F.max_pooling_nd(h, n_points)) 
开发者ID:yukitsuji,项目名称:voxelnet_chainer,代码行数:26,代码来源:light_voxelnet.py

示例3: __call__

# 需要导入模块: from chainer import functions [as 别名]
# 或者: from chainer.functions import tile [as 别名]
def __call__(self, x, pid):
        x = self.bn(x)
        x = F.swapaxes(x, axis1=1, axis2=3)
        y = F.expand_dims(F.expand_dims(pid, axis=-1), axis=-1)
        y = F.tile(y, reps=(1, 1, self.audio_window_size, 1))
        x = F.concat((x, y), axis=1)
        x = self.branch(x)
        x = F.reshape(x, shape=(x.shape[0], -1))
        x = F.concat((x, pid), axis=1)
        x = self.fc1(x)
        x = F.tanh(x)
        x = self.fc2(x)
        return x 
开发者ID:osmr,项目名称:imgclsmob,代码行数:15,代码来源:voca.py

示例4: categorical_kl

# 需要导入模块: from chainer import functions [as 别名]
# 或者: from chainer.functions import tile [as 别名]
def categorical_kl(params0, params1):
    params0 = params0[0]
    params1 = params1[0]
    assert params0.shape == params1.shape
    a0 = params0 - F.tile(F.max(params0, axis=1, keepdims=True), (1, 4))
    a1 = params1 - F.tile(F.max(params1, axis=1, keepdims=True), (1, 4))
    ea0 = F.exp(a0)
    ea1 = F.exp(a1)
    z0 = F.tile(F.sum(ea0, axis=1, keepdims=True), (1, 4))
    z1 = F.tile(F.sum(ea1, axis=1, keepdims=True), (1, 4))
    p0 = ea0 / z0
    return F.sum(p0 * (a0 - F.log(z0) - a1 + F.log(z1)), axis=1) 
开发者ID:openai,项目名称:EPG,代码行数:14,代码来源:utils.py

示例5: _process_trajectory

# 需要导入模块: from chainer import functions [as 别名]
# 或者: from chainer.functions import tile [as 别名]
def _process_trajectory(self, traj):
        proc_traj_in = F.concat(
            [traj] + self._pi_f(traj[..., :self._env_dim]) + \
            [F.tile(self._mem.f(), (traj.shape[0], 1)).data],
            axis=1
        )
        return self._loss.process_trajectory(proc_traj_in) 
开发者ID:openai,项目名称:EPG,代码行数:9,代码来源:agents.py

示例6: _compute_loss

# 需要导入模块: from chainer import functions [as 别名]
# 或者: from chainer.functions import tile [as 别名]
def _compute_loss(self, traj, processed_traj):
        loss_inputs = [traj, processed_traj] + \
                      self._pi_f(traj[..., :self._env_dim]) + \
                      [F.tile(self._mem.f(), (traj.shape[0], 1))]
        loss_inputs = F.concat(loss_inputs, axis=1)
        epg_surr_loss = self._loss.loss(loss_inputs)
        return epg_surr_loss 
开发者ID:openai,项目名称:EPG,代码行数:9,代码来源:agents.py

示例7: _pi_f

# 需要导入模块: from chainer import functions [as 别名]
# 或者: from chainer.functions import tile [as 别名]
def _pi_f(self, x):
        return [self._pi.f(x), F.tile(self._logstd, (x.shape[0], 1))] 
开发者ID:openai,项目名称:EPG,代码行数:4,代码来源:agents.py

示例8: forward_expected

# 需要导入模块: from chainer import functions [as 别名]
# 或者: from chainer.functions import tile [as 别名]
def forward_expected(self, inputs):
        x, = inputs
        y_expected = numpy.tile(x, self.reps)
        return y_expected, 
开发者ID:chainer,项目名称:chainer,代码行数:6,代码来源:test_tile.py

示例9: forward

# 需要导入模块: from chainer import functions [as 别名]
# 或者: from chainer.functions import tile [as 别名]
def forward(self, inputs, devices):
        x, = inputs
        y = functions.tile(x, self.reps)
        return y, 
开发者ID:chainer,项目名称:chainer,代码行数:6,代码来源:test_tile.py

示例10: test_value_error

# 需要导入模块: from chainer import functions [as 别名]
# 或者: from chainer.functions import tile [as 别名]
def test_value_error(self):
        x = numpy.random.uniform(-1, 1, (2,)).astype(numpy.float32)
        with self.assertRaises(ValueError):
            functions.tile(x, self.reps) 
开发者ID:chainer,项目名称:chainer,代码行数:6,代码来源:test_tile.py

示例11: test_reps_not_int

# 需要导入模块: from chainer import functions [as 别名]
# 或者: from chainer.functions import tile [as 别名]
def test_reps_not_int(self):
        with self.assertRaises(TypeError):
            functions.tile(self.x, 'a') 
开发者ID:chainer,项目名称:chainer,代码行数:5,代码来源:test_tile.py

示例12: test_x_not_ndarray_or_variable

# 需要导入模块: from chainer import functions [as 别名]
# 或者: from chainer.functions import tile [as 别名]
def test_x_not_ndarray_or_variable(self):
        with self.assertRaises(TypeError):
            functions.tile((self.x, self.x), 2) 
开发者ID:chainer,项目名称:chainer,代码行数:5,代码来源:test_tile.py

示例13: negative_log_likelihood

# 需要导入模块: from chainer import functions [as 别名]
# 或者: from chainer.functions import tile [as 别名]
def negative_log_likelihood(self, x, y):
        pi, mu, log_var = self.get_gaussian_params(x)

        # Likelihood over different Gaussians
        y = F.tile(y[:, None, :], (1, self.gaussian_mixtures, 1))
        pi = F.tile(F.expand_dims(pi, 2), (1, 1, self.input_dim))
        
        squared_sigma = F.exp(log_var)
        sigma = F.sqrt(squared_sigma)
        prob = F.sum(pi * distributions.Normal(mu, sigma).prob(y), axis=1)
        
        negative_log_likelihood = -F.log(prob)
        return F.mean(negative_log_likelihood) 
开发者ID:chainer,项目名称:models,代码行数:15,代码来源:mdn.py

示例14: look_at

# 需要导入模块: from chainer import functions [as 别名]
# 或者: from chainer.functions import tile [as 别名]
def look_at(vertices, eye, at=None, up=None):
    """
    "Look at" transformation of vertices.
    """
    assert (vertices.ndim == 3)

    xp = chainer.cuda.get_array_module(vertices)
    batch_size = vertices.shape[0]
    if at is None:
        at = xp.array([0, 0, 0], 'float32')
    if up is None:
        up = xp.array([0, 1, 0], 'float32')

    if isinstance(eye, list) or isinstance(eye, tuple):
        eye = xp.array(eye, 'float32')
    if eye.ndim == 1:
        eye = cf.tile(eye[None, :], (batch_size, 1))
    if at.ndim == 1:
        at = cf.tile(at[None, :], (batch_size, 1))
    if up.ndim == 1:
        up = cf.tile(up[None, :], (batch_size, 1))

    # create new axes
    z_axis = cf.normalize(at - eye)
    x_axis = cf.normalize(neural_renderer.cross(up, z_axis))
    y_axis = cf.normalize(neural_renderer.cross(z_axis, x_axis))

    # create rotation matrix: [bs, 3, 3]
    r = cf.concat((x_axis[:, None, :], y_axis[:, None, :], z_axis[:, None, :]), axis=1)
    if r.shape[0] != vertices.shape[0]:
        r = cf.broadcast_to(r, (vertices.shape[0], 3, 3))

    # apply
    # [bs, nv, 3] -> [bs, nv, 3] -> [bs, nv, 3]
    if vertices.shape != eye.shape:
        eye = cf.broadcast_to(eye[:, None, :], vertices.shape)
    vertices = vertices - eye
    vertices = cf.matmul(vertices, r, transb=True)

    return vertices 
开发者ID:hiroharu-kato,项目名称:neural_renderer,代码行数:42,代码来源:look_at.py

示例15: _compute_ddqn_losses

# 需要导入模块: from chainer import functions [as 别名]
# 或者: from chainer.functions import tile [as 别名]
def _compute_ddqn_losses(self, exp_batch, errors_out=None):
        """Compute the Q-learning losses for a batch of experiences

        Args:
          exp_batch (dict): A dict of batched arrays of transitions
        Returns:
          Computed loss from the minibatch of experiences
        """
        y, t = self._compute_y_and_ts(exp_batch)
        n_branches = exp_batch['action'].shape[1]

        # Calculate the errors_out for priorities with the 1-step err
        del errors_out[:]
        delta = F.absolute(y - t)
        if delta.ndim == 2:
            delta = F.sum(delta, axis=1)
        delta = cuda.to_cpu(delta.array)
        for e in delta:
            errors_out.append(e)

        is_1_step = self.xp.abs(1. - exp_batch["is_n_step"]).reshape(-1, 1)
        is_1_step = self.xp.tile(is_1_step, (1, n_branches)).reshape(-1)
        is_n_step = exp_batch['is_n_step'].reshape(-1, 1)
        is_n_step = self.xp.tile(is_n_step, (1, n_branches)).reshape(-1)
        weights = exp_batch['weights'].reshape(-1, 1)
        weights = F.tile(weights, (1, n_branches)).reshape(-1)
        loss_1step = compute_weighted_value_loss(
            y, t, weights,
            mask=is_1_step,
            clip_delta=self.clip_delta,
            batch_accumulator=self.batch_accumulator)
        loss_nstep = compute_weighted_value_loss(
            y, t, weights,
            mask=is_n_step,
            clip_delta=self.clip_delta,
            batch_accumulator=self.batch_accumulator)

        return loss_nstep, loss_1step 
开发者ID:minerllabs,项目名称:baselines,代码行数:40,代码来源:dqfd.py


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